0

Can someone Explain please.!?

while giving a challenge i got this question and it seems bit hard to me the code is: string x=""; string y"sololearn"; x+=y.substring(8,1); x+=y.substring(5,3); console.write(x); Ans : near (how?)

29th May 2017, 7:04 AM
Arjun Gupta
Arjun Gupta - avatar
3 odpowiedzi
+ 6
i dont c#. but y.substring(8,1) = n y.substring(5,3) = ear
29th May 2017, 7:12 AM
jay
jay - avatar
+ 6
Syntax of substring is- stringName.substring(index from, length of substring); Jay has described the rest
29th May 2017, 7:39 AM
Sachin Artani
Sachin Artani - avatar
0
step through the code, use break points, and output in between answers. += stands for x = x + ... in the first line x is empty. The result of the substring is 'n'. That makes the x = 'n' in the second line x = 'n' and the result of the substring is 'ear'. Which makes the finale result. 'n' + 'ear' = 'near'.
29th May 2017, 7:45 PM
sneeze
sneeze - avatar