I'm a newbie to Javascript please help me to solve my problem
function myFunction() {
var fr = ["banana", "orange", "apple", "mango"];
var n = fr.length;
var s = "a";
for(i=0;i<n;i++){
if(fr[i].indexOf(s) != -1){
console.log(fr[i]);
}
}
}
and the output im getting is
banana
orange
apple
mango
but what i want is that it should print only the word that starts with the given letter/word
i.e., : apple