Why would indexOf method give me a -1 as an output ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why would indexOf method give me a -1 as an output ?

19th Sep 2018, 11:05 PM
Alexis C. Student
Alexis C. Student - avatar
2 Answers
+ 6
-1 means here that it's index cannot be found, so the letter or char sequence you looked for isn't present in the string.
19th Sep 2018, 11:15 PM
Jonas Schröter
Jonas Schröter - avatar
+ 4
It just means your target was not found.
19th Sep 2018, 11:32 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar