Trouble with final ā€œWordsā€ Project on JavaScript | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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 Respostas
+ 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