- 1
Who can help me below javascript exercise?
You are making a text encryptor. It should take multiple words and output a combined version, where each word is separated by a dollar sign $. For example, for the words "hello", "how", "are", "you", the output should be "$hello$how$are$you
quot;. The given code declares a class named Add, with a constructor that takes one rest parameter. Complete the code by adding a print() method to the class, which should generate the requested output.8 Réponses
+ 3
Tâm Trần Ngọc please give the name of problem you face
+ 2
Abhay please tell the name of the question
+ 1
Have you tried yourself?
+ 1
Tâm Trần Ngọc
Change your print method code to following one:
print(){
var str=this.words.join("quot;);
console.log("quot;+str+"quot;);
};
Also remember that using return stops execution of program and you exit the function.
So try to understand what each of those words mean .
+ 1
That right. Thank you everyone 😊
0
Yes. I have. This is a exercise in javascript course and this is my code
class Add {
constructor(...words) {
this.words = words;
}
//your code goes here
print(){
for(var s in this.words){
return console.log("quot;+this.words[s]+"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();
0
Tanmay Prakash Powar run the code , you will see the problem yourself.
0
Tanmay Prakash Powar question is in description .