0

What’s wrong?????

class Add { constructor(...words) { this.words = words; } //your code goes here print() { var f = this.words.toString(); f = replaceAll(f, ",", "

quot;); console.log(f + "
quot;) } } 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(); function replaceAll(str, st1, st2) { return str.split(st1).join(st2); } // Note : that the dollar sign is placed at the beginning and at the end of the output.

12th Dec 2020, 4:35 PM
Amine Elmestoui
6 Respuestas
0
Amine Elmestoui Just do console.log("
quot; + (this.words).join("
quot;) + "
quot;);
12th Dec 2020, 4:56 PM
A͢J
A͢J - avatar
+ 1
class Add { constructor(...words) { this.words = words; this.curWord = ""; } //your code goes here print(){ this.curWord = ""; this.words.map((el,i)=>{ this.curWord+="
quot;+el; }); console.log(this.curWord+"
quot;); } } 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(); You have to do something like this Plz read the hint that is given in the code coach
13th Dec 2020, 5:16 AM
Coder
Coder - avatar
0
What do you want to do here?
12th Dec 2020, 4:43 PM
Muhammadamin
Muhammadamin - avatar
0
You don't have "
quot; at the beginning. That's not big a problem. The critical is there in z there is a string "," which won't make your solution works
12th Dec 2020, 4:44 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
CarrieForle what I should do to my code work ??
12th Dec 2020, 4:46 PM
Amine Elmestoui
0
You need to rethink your algorithm because in z there is a string is literally ",". It will make an extra dollar sign, leading the failure.
12th Dec 2020, 4:49 PM
你知道規則,我也是
你知道規則,我也是 - avatar