1

Okay this is what I'm trying to do:

var number = 3
var numberArray = [1, 2, 3, 4, 5]
if number = numberArray[one of the indexes] {
// do something
}

can anybody help?

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
Benja0906
  • 1,437
  • 2
  • 15
  • 25
  • what is `one of the indexes` supposed to do? Do you want to check whether `number` is in the array? Then go for `contains`. – Sulthan Jan 19 '16 at 15:54

1 Answers1

4

If I understand your question correctly, what you want is contains:

var number = 3
var numberArray = [1, 2, 3, 4, 5]
if numberArray.contains(number) {
    // do something
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253