Cheers,
The function receives an array parameter, I set up an if to count the number of times this array contains the String "buena" . But my code only recognizes the "buena" String once when it really has 3. I appreciate your help. Thank you
function ideas(array) {
var contador = 0;
for (var i = 0; i < array.length; i++) {
if(array[i] === "buena"){
contador += 1;
if(contador >2){
return "Jackpot!"
}
else if (contador <2){
return "Activa!"
}
else if (contador <= 0){
return "Fail!"
}
}
}
}
console.log(ideas(([
'hola',
'palabra',
'buena',
'hi',
'buena',
'buena'
])));