Source Code:
(back to article)
Submit
Result:
Report an issue
var array = [11, 20, 8, 6, 17]; var el = 6; //Element to be searched var flag = 0; // Initially 0 - Not found for(var i=0; i<array.length; i++) { if(el === array[i]) { flag = 1; } } //Check if flag value changed. if(flag == 1) { console.log('Element Found'); } else { console.log('Element Not Found'); }