+ 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
5 ответов
+ 3
The creator of the quiz explained it here.
https://www.sololearn.com/discuss/1410807/?ref=app
+ 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"
+ 3
Nguyễn Văn Hoàng thanks.
+ 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.
- 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"