- 4
You are making a text encryptor. It should take multiple words and output a combined version, where each word is separated by a
2 Antworten
+ 9
Shivani Patel
No need to replace anything and also no need of loop here. You can just do this:
console.log("quot; + (this.words).join("quot;) + "quot;);
+ 2
class Add {
constructor(...words) {
this.words = words;
}
//your code goes here
print(){
var y ="";
for(x of this.words){
x=x.replace(/[^a-zA-Z ]/g, "")
if(x!=""){
y += '#x27;+x;
}
}
console.log(y+'#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");
x.print();
y.print();
z.print();