<html> <script> var string = "I love Sololearn!"; var search = string.search("Sololearn"); alert(search); </script> </html>

Please help me out with the output of this code and explain to me how it works

11th May 2018, 6:12 PM
Williams - avatar
3 Respuestas
+ 2
it's just searching the sololearn in the string which is situated at 8 position so after 7 the search is match so alert is displayed 7 as output
11th May 2018, 6:19 PM
MsJ - avatar
+ 3
output will be 7, it returns the position (index) of the first letter of that word (sololearn)
11th May 2018, 6:19 PM
Kawaii - avatar
+ 1
Thanks a lot for the answers, I now understood it
11th May 2018, 6:25 PM
Williams - avatar