0
I can't solve this problem in any way, please help someone
class Add{ constructor(...words){ this.words = words; } print(){ var str = this.words.filter((value)=>/^[a-z]+$/i.test(value)).join("
quot;); var b = "quot;+str+"quot;; console.log(b); } } var x = new Add("hehe", "hoho", "haha"); var y = new Add("this", "is", "awesome"); var z = new Add("lorem", "ipsum", "dolor", ",", "sit"); x.print(); y.print(); z.print();1 Antwoord
+ 1
Your Add class is wrongly structured. There were missing curly brackets and also misplaced curly bracket.
class Add
{
constructor( ...words )
{
this.words = words;
}
print()
{
// using string interpolation
//console.log( `${this.words.join("quot;)}
);
// using string concatenation
console.log( "quot; + this.words.join("quot;) + "quot; );
}
}
You have posted a total of 3 threads on this problem, can you please remove the duplicates? it's not nice to post same problem multiple times.