+ 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();11 Respostas
+ 6
This will help you:
https://code.sololearn.com/WXLXZ2Qi1XIo/?ref=app
+ 2
Hasintha Ranaweera
Just do
console.log("quot; + (this.words).join("quot;) + "quot;);
+ 2
Hasintha Ranaweera It should work. How did you write show me.
+ 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.
+ 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?
+ 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();
0
Not working
0
function print() {
var a = this.words.map((word) => "quot;+word);
console.log("quot; + (this.words).join("quot;) + "quot;);
}
0
Which of the code coach is this one?
0
print(){
console.log('#x27;+this.words.join('#x27;)+'#x27;)
}
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());