Source Code:
(back to article)
Submit
Result:
Report an issue
9
1
2
3
4
5
6
7
8
›
var myArray = ["Rose", "Lily", "Daisy", "Jasmine"];
if (myArray.indexOf(searchTerm) === -1) {
console.log("element doesn't exist");
}
else {
console.log("element found");
}
var myArray = ["Rose", "Lily", "Daisy", "Jasmine"]; if (myArray.indexOf(searchTerm) === -1) { console.log("element doesn't exist"); } else { console.log("element found"); }