-1
I’m trying to do an exercise, but it wasn’t the way the platform wanted, I’ve already spent a few hours trying because I’m beginner and I have no ideas how to solve, could help me?
Enunciation:
A bag assembled a list of the fruits they sell, and according to the fruit the user seeks they want to inform if there is the fruit in the list or not!
var listaDeFrutas = [ "Uva", "Banana", "Manga", "Cajá", "Pinha"]
You should create a loop that checks if the fruit contained in the search variable exists in the bag’s fruit list. If there is just display a message, "Yes, we have banana fruit available". Use the search variable to display the name of the fruit in this message dynamically.
What I wrote:
var listaDeFrutas = [ "Uva", "Banana", "Manga", "Cajá", "Pinha"]
var busca = "Cajá"
//seu loop aqui
for (var i = 0; i < listaDeFrutas.length; i++ ){
if (listaDeFrutas[i] = 3){
}
}
console.log("Sim, temos a fruta disponível")
Error:
You must make a condition to verify that the value of the sought fruit is equal to the value being traversed from the array!
The Ars forgot to read "You must make a condional to check if the value of the search fruit is equal to the value being traversed from the array!"
– Augusto Vasques