$ ./guess_the_languageProblem Solving — fill the blank
Problem Solving — fill the blank · medium · #118

What goes in the blank?

// returns the index of "x", or -1 if not present
function locate(arr, x) {
  return arr.____(x);
}
// locate(["a","x"], "x") -> 1

Answer: indexOf (also accepted: indexOf, indexOf())

indexOf() returns the matching index or -1.
Play Problem Solving ▸