17th Jul 2025, 6:27 PM
Shivam Gupta
Shivam Gupta - avatar
2 Answers
+ 2
Shivam Gupta , > the string method `indexOf()` returns the zero-based index of the first occurrence of a specified character or substring in a given string. > we can also pass an `index value` as a second argument to define where the search should start from. > the method returns `-1` if the passed value can not be found. in your case the search is looking for an upper case "F". but this does not exist in the string. so `-1` will be returned. if we search for "r", the result will be 5.
17th Jul 2025, 6:40 PM
Lothar
Lothar - avatar
17th Jul 2025, 10:19 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar