Skip to content

Instantly share code, notes, and snippets.

@Uvacoder
Forked from emmabostian/loops.js
Created October 23, 2022 14:02
Show Gist options
  • Select an option

  • Save Uvacoder/2cc9398df2bda2b5a9fe0ba6b27bd0e4 to your computer and use it in GitHub Desktop.

Select an option

Save Uvacoder/2cc9398df2bda2b5a9fe0ba6b27bd0e4 to your computer and use it in GitHub Desktop.
function iterate(arr, findMe) {
if (arr[0]) {
if(arr[0] === findMe) {
return true;
}
}
if (arr[1]) {
if (arr[1] === findMe) {
return true;
}
}
if (arr[2]) {
if (arr[2] === findMe) {
return true;
}
}
return false;
}
function loop(arr, findMe) {
for(let item of arr) {
if (item === findMe) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment