const names = ['Rena', 'Carmen', 'Julianne', 'William'] function getNames(names, targetName) { for (let i = 0; i < names.length; i++) { } return targetName === names[i] ? true : false; } console.log(getNames(names, 'Rena')); console.log(getNames(names, 'Carmen')); console.log(getNames(names, 'Julianne')); console.log(getNames(names, 'William'));
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