var array = [2, 9, 9];
array.indexOf(2); // 0
array.indexOf(7); // -1
array.indexOf(9, 2); // 2
array.indexOf(2, -1); // -1
array.indexOf(2, -3); // 0
function quickCheck(arr, elem) {
if (arr.indexOf(elem) >= 0) {
return true;
}
return false;
}
console.log(quickCheck(["squash", "onions", "shallots"], "mushrooms"));
let days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
console.log(days.indexOf('Sunday'));
// --> -1, mert nem található meg
let days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'];
console.log(days.indexOf('Monday'));
// --> 0
function quickCheck(arr, elem) {
return arr.indexOf(elem) >= 0 ? true : false;
}
console.log(quickCheck(["squash", "onions", "shallots"], "mushrooms"));
const fruits = ["Apple", "Orange", "Apple", "Mango"];
let position = fruits.indexOf("Apple") + 1;
function quickCheck(arr, elem) {
return arr.indexOf(elem) != -1;
}
console.log(quickCheck(["squash", "onions", "shallots"], "mushrooms"));
arr.indexOf("jay")
const arr = ["apples", "pears", "plums", "oranges"];
console.log(arr.indexOf("pears"));
arr.indexOf("jay")