I got a question on challenge like var a="I like studying with Sololearn", var b =a.split(" "), document.write(b) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I got a question on challenge like var a="I like studying with Sololearn", var b =a.split(" "), document.write(b)

the answer was given based on assuming var a is an array .The answer was I,like, studying,with,Sololearn. Shouldn't be the answer is undefined.

22nd Dec 2017, 5:14 PM
Saurav Agrawal
Saurav Agrawal - avatar
2 Answers
+ 2
The answer given was correct : 'var a' is a string The result returned (in b) by the split method is an array, where the items are each substring from 'a' surrounded by spaces. Then 'document.write(b)' displays all array elements separated by a comma.
22nd Dec 2017, 6:38 PM
ifl
ifl - avatar
+ 1
Okay I got it.
22nd Dec 2017, 6:43 PM
Saurav Agrawal
Saurav Agrawal - avatar