Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
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();6 Respostas
+ 3
what are you expecting as output?
because your code doesn't help us to understand... :(
+ 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$
+ 1
print() {
console.log(ā#x27;+this.words.join('#x27;)+'#x27;);
}
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
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.