0
Words project
My code class Add { constructor(...words) { this.words = words; } //your code goes here print(){ var y =""; for(x of this.words){ y += `${x}`; } console.log(y); } } 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(); It's showing error why don't know, test is also locked
17 odpowiedzi
+ 1
CarrieForle how did it work?
+ 1
There was a recent update to the supplied code, and it breaks older attempts. My old code once passed, but now fails.
For the correction see my full explanation in this post.
https://www.sololearn.com/Discuss/2630096/?ref=app
0
print = function (){
const myWords = [];
for(let i = 0; i <= this.words.length; i++)
{
myWords.push("quot;)
myWords.push(this.words[i]);
}
const mySentence = myWords.join("")
console.log(mySentence)
}
0
You need another "quot; at the end of the sentence.
0
Words project
My code
class Add {
constructor(...words) {
this.words = words;
}
//your code goes here
print(){
var y ="";
for(x of this.words){
y += `${x}`;
}
console.log(y);
}
}
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();
carrieforle like this ?
0
I mean, add "quot; after every sentence you logged. For example, x.print() should output "$hehe$hoho$haha$hihi$huhuquot;.
But yours is "$hehe$hoho$haha$hihi$huhu".
See the difference?
0
My code
class Add {
constructor(...words) {
this.words = words;
}
//your code goes here
print(){
var y ="";
for(x of this.words){
y += `${x}`;
}
console.log(y);
}
}
var x = new ($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();
It's showing error why don't know, test is also locked
0
something like this?
0
I mean.
In your code:
var x = new Add("hehe", "hoho", "haha", "hihi", "huhu");
x.print();
The output will be "$hehe$hoho$haha$hihi$huhu".
BUT, the output SoloLearn wants is:
"$hehe$hoho$haha$hihi$huhuquot;
Modify your print() and get the output SoloLearn desired. Everything outside of your print() originally is doing great. No need to modify them.
0
please can you send your code so i can understand wha u mean
0
Okay.... Use console.log(`${y}
); in your original code.
0
To be honest i dont understand wha u mean
0
Words project
My code
class Add {
constructor(...words) {
this.words = words;
}
//your code goes here
print(){
var y ="";
for(x of this.words){
y += `${x}`;
}
console.log(‘$y$’);
}
}
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();
It's showing error why don't know, test is also locked
0
something like this?
0
It's console.log("${y}quot;)
0
You wrote console.log("$yquot;);
- 2
what i wrote up there is it correct?