Hello! Can someone help me understand wwhy this loop is returning “undefined”. also, oonce arr has been looped through w/o any instance of “October”, I’d like to return “Have a great day”
function holidays(arr) {
// Do not use a variable to store your result
// ADD CODE HERE
for (let i = 0; i < arr.length; i++) {
if (arr[i] != "October") {
i++
} else if (arr[i] === "October") {
return "Happy Halloween"
}
}
}
// Uncomment these to check your work!
const months = ["April", "May", "June", "October"];
const animals = ["Cats", "Dogs", "Pigs"];
console.log(holidays(months)); // should return: "Happy Halloween"
console.log(holidays(animals)); // should return: "Have a great day!"