A JavaScript to add all words together using text encryptor. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

A JavaScript to add all words together using text encryptor.

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.

9th Jun 2022, 8:02 PM
Adah Godfrey Inalegwu
5 Answers
+ 1
What have you tried? Please show your code.
9th Jun 2022, 8:03 PM
Lisa
Lisa - avatar
+ 1
class Add { constructor(...words) { this.words = words; } //your code goes here } 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();
9th Jun 2022, 8:04 PM
Adah Godfrey Inalegwu
+ 1
Thanks so much for your concerns always... I appreciate everyone's contributions
10th Jun 2022, 7:31 AM
Adah Godfrey Inalegwu
0
godfrey adah class Add { constructor(...words) { this.words = words; } //your code goes here 👇👇👇👇 print() { console.log(`${this.words.join("
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();
10th Jun 2022, 1:13 AM
NonStop CODING
NonStop CODING - avatar
10th Jun 2022, 4:14 AM
JaScript
JaScript - avatar