Anyone know where wrong😢 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Anyone know where wrong😢

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

24th Jul 2021, 1:13 PM
omar
omar - avatar
2 Answers
+ 1
Is print a method of your class coz I see, it's not defined.
24th Jul 2021, 1:48 PM
Kirabo Ibrahim
Kirabo Ibrahim - avatar
+ 1
Define a print() method in your class, I assume you want output the words property, you may console.log() in the print() method to output the words property bounded value.
24th Jul 2021, 1:59 PM
Kirabo Ibrahim
Kirabo Ibrahim - avatar