/* 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);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter