var libraryLetter = ["book", "car", "bank", "near", "between", "map", "dog"];
var userLetter = prompt("Укажите буквы через запятую");
for (var i = 0; i < libraryLetter.length; i++) {
if(libraryLetter.indexOf(userLetter) == true){
????
}else {
console.log("Совпадений не найдено");
}
};
function inArray(arr, str) {
return arr.filter(function(item) {
return item.indexOf(str) !== -1
})
}
var words = inArray(libraryLetter, 'a')
if (words.length > 0 ) {
console.log(words)
} else {
console.log('Совпадений не найдено')
}
var libraryLetter = ["book", "car", "bank", "near", "between", "map", "dog"];
var userLetter = prompt("Укажите букву");
for (var i = 0; i < libraryLetter.length; i++) {
if(libraryLetter[i].indexOf(userLetter) > -1){
????
}else {
console.log("Совпадений не найдено");
}
};
var libraryLetter = ["book", "car", "bank", "near", "between", "map", "dog"];
var userLetter = prompt("Укажите букву");
var filteredwords = libraryLetter.filter(function(value) {
return value.indexOf(userLetter) > -1
})
if(filteredwords.length ){
????
}else {
console.log("Совпадений не найдено");
};
var libraryLetter = ["book", "car", "bank", "near", "between", "map", "dog"];
var userLetter = prompt("Укажите букву");
for (var i = 0; i < libraryLetter.length; i++) {
if(libraryLetter[i].indexOf(userLetter) == 0){
console.log("Совпадение " + libraryLetter[i]);
}else {
console.log("Совпадений не найдено");
}
};
(libraryLetter[i].indexOf(userLetter) == 0)
libraryLetter[i]
начинается с userLetter