Who can help me below javascript exercise? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 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.

20th Jan 2021, 2:40 PM
Tâm Trần Ngọc
Tâm Trần Ngọc - avatar
8 Answers
+ 3
Tâm Trần Ngọc please give the name of problem you face
20th Jan 2021, 3:00 PM
Tanmay Prakash Powar
Tanmay Prakash Powar - avatar
+ 2
Abhay please tell the name of the question
20th Jan 2021, 3:09 PM
Tanmay Prakash Powar
Tanmay Prakash Powar - avatar
+ 1
Have you tried yourself?
20th Jan 2021, 2:41 PM
Zohaib 👑
Zohaib 👑 - avatar
+ 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 .
20th Jan 2021, 3:08 PM
Abhay
Abhay - avatar
+ 1
That right. Thank you everyone 😊
20th Jan 2021, 8:54 PM
Tâm Trần Ngọc
Tâm Trần Ngọc - avatar
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();
20th Jan 2021, 2:45 PM
Tâm Trần Ngọc
Tâm Trần Ngọc - avatar
0
Tanmay Prakash Powar run the code , you will see the problem yourself.
20th Jan 2021, 3:08 PM
Abhay
Abhay - avatar
0
Tanmay Prakash Powar question is in description .
20th Jan 2021, 3:21 PM
Abhay
Abhay - avatar