Why would indexOf method give me a -1 as an output ? | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 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 Respuestas
+ 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