I am working on some code that I need urgent help with. I keep getting the same results from this code and I urgently need some assistance. Please see below. I cannot figure out why I always get the value that I pass into the array and the if statement is not working?
This code must not change from the below array and function calls.
var fruit = ["Apple","Orange","Strawberry"];
var elementTwo = "Apple";
function favoriteFruit(elementOne,elementTwo){
if(elementOne === elementTwo){
return true;
}else{
return false;
}
}
fruit = fruit.filter(function(elem)
{
return favoriteFruit("Orange", elem);
})[0];
console.log(fruit);
Aucun commentaire:
Enregistrer un commentaire