function check_color(){
color_input = prompt("I am thinking of one of these colors: \n\n"+
"blue, cyan, gold, gray, magenta, orange, red, white, yellow \n\n"+
"What color am I thinking of?");
if(color_input != null || color_input != undefined){
if(typeof (color_input) != 'string') {
alert("This is not any color. \n\n"+
"Please enter color in text format");
return false;
}
if(colors.indexOf(color_input) < 0){
alert("Sorry, i don't recognize your color. \n\n"+
"Please try again");
return false;
}
}
else{
alert("Please enter some input");
return false;
}
}
为什么在尝试运行此代码时总是执行第一个 if block ?有人可以解释一下吗?
最佳答案
“颜色”在哪里 if(colors.indexOf(color_input)
我在这里收到控制台错误。 请添加颜色数组
关于javascript提示返回类型总是object?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39145237/