\n","text":"Please help me out with the output of this code and explain to me how it works","answerCount":3,"upvoteCount":0,"acceptedAnswer":{"@type":"Answer","text":"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","upvoteCount":2},"suggestedAnswer":[{"@type":"Answer","text":"output will be 7, it returns the position (index) of the first letter of that word (sololearn)","upvoteCount":3},{"@type":"Answer","text":"Thanks a lot for the answers,\nI now understood it","upvoteCount":1}]} }
0

<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
Oodo Roland Uchenna
Oodo Roland Uchenna - avatar
3 ответов
+ 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
MsJ - avatar
M
+ 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
Kawaii - avatar
+ 1
Thanks a lot for the answers, I now understood it
11th May 2018, 6:25 PM
Oodo Roland Uchenna
Oodo Roland Uchenna - avatar