0

[Solved] Why my code of last project in JavaScript (words) correctly worked in ideaone, but not worked in SoloLearn?

My code correctly worked in ideaone ( https://ideone.com/yxbykK ) but failed in SoloLearn. What I doing wrong? My output: $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ My code: class Add { constructor(...words) { this.words = words; } print() { var s = "

quot;; if (this.words.length > 0) { this.words.map(w => {s += w + "
quot;}); } else { s += "
quot;; } console.log(s); } } var x = new Add("hehe", "hoho", "haha", "hihi", "huhu"); var y = new Add("this", "is", "awesome"); var z = new Add("lorem", "ipsum", "dolor", "sit", "amet", ",", "consectetur", "adipiscing", "elit"); x.print(); y.print(); z.print(); P.S: On my Huawei phone I can't see any solutions by links in sololearn because it used google services. In my Huawei all google services are not avalible.

8th Jan 2021, 6:58 AM
Sergey Lavrov
Sergey Lavrov - avatar
2 Réponses
+ 1
in the last test case of obiect z you have added a new element "," which is also apearing in your output.. that is not required
8th Jan 2021, 7:26 AM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
Thank you. After deleting element "," in varible z test was passed. But why this element was in start code I don't know.
8th Jan 2021, 8:01 AM
Sergey Lavrov
Sergey Lavrov - avatar