I am a beginner at JavaScript (beginner as in studying for about a week) and I'm stuck on how I can check if an array contains a certain string. Here I've made a word-guessing game.
I declare the function
'contains' like this:
function contains(thing, array){
if(thing in array){
return true;
}
else {
return false;
}
};
I'm not sure what I'm doing wrong, but the value is always false.
The function uses the third technique here. But I've also tried using the accepted technique here, both with the same result.
Any help is greatly appreciated!