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.6 Respuestas
0
Amine Elmestoui
Just do
console.log("quot; + (this.words).join("quot;) + "quot;);
+ 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
0
What do you want to do here?
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
0
CarrieForle what I should do to my code work ??
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.