I'm looking for a method to determine whether the word "miami" is present in this array and then display a message confirming its existence. I am contemplating whether to utilize a for loop or forEach loop. How can I verify if the word "miami" exists in the array below?
let targetWord = "miami";
let wordsArray = ["bcn", "mia", "sao", "mex", "par", "miami", "ams", "ber", "paris", "lis", "mad"];
for (let i = 0; i < wordsArray.length; i++) {
if (wordsArray[i] === targetWord) {
console.log("True - 'miami' exists in the array.");
break;
} else {
console.log(wordsArray[i]);
}
}