-6

I recently starting learning JS so a beginner level answer would be great! Thanks.

function contains(arr, item) {
   // check to see if item is inside of arr
   // return true if it is, otherwise return false

}
Liv Marx
  • 305
  • 1
  • 6
  • 12
  • 1
    `return arr.includes(item)` – gurvinder372 Apr 05 '18 at 13:01
  • 2
    [.includes()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) and [.find()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) – Mohammad Usman Apr 05 '18 at 13:01

1 Answers1

0

What about something like this?

const arr = [1,2,3];
const el = 2;
console.log(arr.includes(el)) // true
manelescuer
  • 827
  • 1
  • 9
  • 19