var n = new Array();
n[0] = "zero";
n[1] = "first";
n[2] = "second"
function myFunction() {
var x = prompt("Question?")
if (x.toLowerCase() == n) {
//code
} else {
//code
}
}
Is it possible to make it so that if any of the array variables are typed in, the if / else function is still carried out.
(x..==n)just makes it so that when the letter "n" is typed into the prompt box the statements are carried out.x.toLowerCase() == nwill not be true when the letternis typed into the input box.nis an array of the strings"zero", "first", "second", and is not equal to the string"n". Just to recap,nis an array,x.toLowerCase()is a string that contains the lowercased input. You are checking whether a string equals an array, which is false.