+ 3

Can someone please explain me this js code?

Can someone please explain me this code? let [learn,solo="solo"] = "learn"; [solo, learn] = [learn, solo]; console.log(solo + learn); //le I think it has to do with ES6 and I don't fully understand this lesson. https://www.sololearn.com/learn/519/?ref=app

28th Sep 2018, 9:12 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
5 Answers
+ 3
The creator of the quiz explained it here. https://www.sololearn.com/discuss/1410807/?ref=app
28th Sep 2018, 9:24 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 4
sorry my mistake... should be let [learn,solo="solo"] = "learn"; // learn = "l", solo = "e" [solo, learn] = [learn, solo]; // solo = "l", learn = "e" (exchange) console.log(solo + learn); // solo + learn = "le"
28th Sep 2018, 9:26 AM
CalviŐ˛
CalviŐ˛ - avatar
28th Sep 2018, 9:27 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
+ 2
CalviŐ˛ I also thought the output would be "learnsolo" but when I tested it in the code playground the output was "le". Don't know why though. This was actually a challenge.
28th Sep 2018, 9:24 AM
Shuaib Nuruddin
Shuaib Nuruddin - avatar
- 2
let [learn,solo="solo"] = "learn"; // learn = "learn", solo = "solo" [solo, learn] = [learn, solo]; // solo = "learn", learn = "solo" console.log(solo + learn); // solo + learn = "learnsolo"
28th Sep 2018, 9:21 AM
CalviŐ˛
CalviŐ˛ - avatar