4-Array_Search
Thu Sep 22 2022 01:41:07 GMT+0000 (Coordinated Universal Time)
Saved by
@Vrushabh_123
/*
Function to Search a given element inside an array
@param element
*/
const searchElement = (element) => {
const data = [20, 40.6, 70, 20, 22, 66];
for (let i = 0; i <= data.length - 1; i++) {
if (data[i] === element) {
console.log(`Element Found at ${i}`);
break;
}
}
console.log("No Element Found");
};
searchElement(126);
content_copyCOPY
Comments