+ 4

How to solve javascript words coach problem ??

class Add { constructor(...words) { this.words = words; this.print = print; } } function print() { var a = this.words.map((word) => "

quot;+word); var b = a.join(""); console.log(b+"
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();

3rd Jan 2021, 3:28 AM
{H}asintha Ranaweera
{H}asintha Ranaweera - avatar
11 Respostas
3rd Jan 2021, 12:00 PM
JaScript
JaScript - avatar
+ 2
Hasintha Ranaweera Just do console.log("
quot; + (this.words).join("
quot;) + "
quot;);
3rd Jan 2021, 4:14 AM
A͢J
A͢J - avatar
+ 2
Hasintha Ranaweera It should work. How did you write show me.
3rd Jan 2021, 4:21 AM
A͢J
A͢J - avatar
+ 2
Hasintha Ranaweera I did the same but now my code is also not working. I think there is bug because everyone solved this with same code.
3rd Jan 2021, 4:28 AM
A͢J
A͢J - avatar
+ 2
What does "print(eachtem)" in the code does. Well I thought it defines the $ thing to be in the words and needs a simple console.log statement. But if so, then isn't another $ placement in the function being a wrong code? Anyone with me?
25th Aug 2021, 2:04 PM
Courage Asraku
Courage Asraku - avatar
+ 1
class Add { constructor(...words) { this.words = words; } //your code goes here print(){ let doller = "
quot;; for(let value of this.words) doller = doller+(value+"
quot;); console.log(doller); } } 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();
30th Mar 2022, 1:57 PM
Aarav Tomar
0
Not working
3rd Jan 2021, 4:20 AM
{H}asintha Ranaweera
{H}asintha Ranaweera - avatar
0
function print() { var a = this.words.map((word) => "
quot;+word); console.log("
quot; + (this.words).join("
quot;) + "
quot;); }
3rd Jan 2021, 4:25 AM
{H}asintha Ranaweera
{H}asintha Ranaweera - avatar
0
Which of the code coach is this one?
4th Jan 2021, 11:36 AM
Umar Fahm
Umar Fahm - avatar
0
print(){ console.log('
#x27;+this.words.join('
#x27;)+'
#x27;) }
21st Jan 2021, 8:09 PM
Nami
Nami - avatar
0
the solution is very simple . class Add { constructor(...words) { this.words = words; } //your code goes here print (){ return `${this.words.join('
#x27;)} } } 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"); console.log(x.print()); console.log(y.print()); console.log(z.print());
16th Oct 2022, 4:24 PM
Nweke Ogechi
Nweke Ogechi - avatar