function food(){
var food_choice = document.getElementById('food-ch').value;
console.log(food_choice);
var food_arr = ['tuna','salmon','prawn','chicken'];
for(key in food_arr){
if(food_choice === food_arr[key]){
console.log(food_arr[key]);
$('#display-food').html("You have chosen "+food_arr[key]);
}
else{
$('#display-food').html("Please try again");
}
}
}
I encountered an issue with the code above. Despite entering one of the items from the array, it consistently directed me to the 'else' part.