0

what is the wrong of this code?

class Add { constructor(...words) { this.words = words; } //your code goes here get dollar(){ return this.print; } print(){ var sent=[] for(let g in this.words){ sent.push('

#x27;+this.words[g]+'
#x27;) } console.log('"'+sent.join('')+'"'); } } 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();

27th Dec 2020, 10:21 AM
Mohammed Ali Shahin
Mohammed Ali Shahin - avatar
2 Answers
+ 1
You need to change at least 2 things in you code to pass the test case. 1. Remove value "," from input in var z. 2. change the logic in print method. Tip: you can use the following line in print method. console.log("
quot; + this.words.join("
quot;) + "
quot;) https://www.sololearn.com/post/838036/?ref=app
27th Dec 2020, 10:27 AM
Art1mis