Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
indexOf() method returns -1 when item is present in list

let mobile = [
  "‭+9384849202",
  "‭+5808789645",
  "‭+0989645643",
  "‭+7864769845",
]

console.log(mobile.indexOf("+7864769845"))

the result of this is -1 when the expected result is 3

thought it was a type error at first, but now I'm not sure?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is a hidden zero-width "invisible" character at the start of each string in the array. If you delete them, it works as expected.

let mobile = [
  "+9384849202",
  "+5808789645",
  "+0989645643",
  "+7864769845",
]

console.log(mobile.indexOf("+7864769845"))

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!