+ 1

need help

Complete the code by adding a print() method to the class, which should generate the requested output. Note, that the dollar sign is placed at the beginning and at the end of the output. For example, for the words "hello", "how", "are", "you", the output should be "$hello$how$are$you

quot;. 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();

21st Oct 2022, 6:54 AM
danielSeyfu
danielSeyfu - avatar
1 Answer
+ 5
You have to code a getter function in the class, which return the words in format as in the description.
21st Oct 2022, 7:16 AM
JaScript
JaScript - avatar