0

Trouble with final “Words” Project on JavaScript

I’ve been trying to figure this out and have read and reread all of Ecma 6 and I’m still lost. Here’s the code I tried and I’ve tried many others but I feel like I have no general direction for what I’m doing. class Add { constructor(...words) { this.words = words; } //my code here print() { Add.forEach(words => { console.log("

quot;); }) } //my code above 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();

6th Feb 2021, 2:13 AM
Mark
Mark - avatar
6 odpowiedzi
+ 3
what are you expecting as output? because your code doesn't help us to understand... :(
6th Feb 2021, 2:18 AM
visph
visph - avatar
+ 1
sorry, the output is supposed to output every word for every variable with a dollar sign before and behind it. Ex: $this$is$awesome$
6th Feb 2021, 2:21 AM
Mark
Mark - avatar
+ 1
print() { console.log(☆
#x27;+this.words.join('
#x27;)+'
#x27;); }
6th Feb 2021, 2:29 AM
visph
visph - avatar
0
class Add { constructor(...words) { this.words = words; } //my code here print() { this.words.forEach(word => { console.log(`${word}`); }) } } //my code above 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(); you forgot to close class Add , didnt put this.words in forEach
6th Feb 2021, 2:29 AM
Veljko
Veljko - avatar
0
for either adjustment to the codes that were suggested, i get the same syntax error saying that var x = new Add is an unexpected identifier.
6th Feb 2021, 3:02 AM
Mark
Mark - avatar