+ 1
What is wrong with this js code?
Last ecmas6 project class Add { constructor(...words) { this.words = words; } print(){ var r = "" for(let w of this.words){ r+= "
quot;+w+"quot; }return r } } 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();2 Answers
+ 2
Thanks mate! It did really help!
+ 1
It does compile but doesn't print anything. you might be missing a console.log
either
console.log(x.print());
or
print(){
// your code
console.log(r); // instead of return r
}
I hope this helps :)