var commonWords = [
"the","of","and","a","to","in","is","you","that","it","he",
"was","for","on","are","as","with","his","they","I","at","be",
"this","have","from","or","one","had","by","word","but","not",
"what","all","were","we","when","your","can","said","there",
"use","an","each","which","she","do","how","their","if","will",
"up","other","about","out","many","then","them","these","so",
"some","her","would","make","like","him","into","time","has",
"look","two","more","write","go","see","number","no","way",
"could","people","my","than","first","water","been","call",
"who","oil","its","now","find","long","down","day","did","get",
"come","made","may","part"
];
var myFavoriteInstructors = ["Patrick", "Kenji", "J-Wo", "Azam", "Dorton"];
// Create a function that choses a random word from `commonWords` and returns it
var chooseRandomWord = function(array) {
var index = Math.floor((Math.random() * array.length));
return array[index];
}
var chosenWord = chooseRandomWord(commonWords);
var counter = 10;
var triedCharacters = [];
var correctCharacters = [];
var chosenWordSplit = chosenWord.split("");
var checkForCharacter = function(character) {
for(let i = 0; i < chosenWordSplit.length; i++){
if(character === chosenWordSplit[i]){
console.log("Match found!");
return true;
} else {
console.log("Match not found.");
return false;
}
}
}
checkForCharacter("a");
console.log(chosenWordSplit);