这是用javascript编写的,使用智能脸云IDE。但由于某种原因,我可以将部件与列表/数组进行比较。请帮忙!!任何建议或意见将不胜感激!
var dropC = "green red blue blue blue"
var dropColors = dropC.split(" ");
var colors = ["green", "blue", "red", "yellow"];
var l = 1
var dropColor;
if (dropColors[l] == colors[0]) {
dropColor = "green";
} else if (dropColors[l] == colors[1]) {
dropColor = "blue";
} else if (dropColors[l] == colors[2]) {
dropColor = "red";
} else if (dropColors[l] == colors[3]) {
dropColor = "yellow";
} else {
dropColor = "Error";
}
alert(dropColor);
无论l的值如何,结果总是“错误”。