Javascript final module project | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Javascript final module project

Whenever I submit, server says error. Help me to this please: My code: class Add { constructor(...words) { this.words = words; } print() { let d = "

quot;; for(let a of this.words) { let arr = [a]; for(let b= 0; b< arr.length ; b++) { if (b< arr.length) { d = d + `${arr[b]} ; } else return d; } } } console.log(d) ; } 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();

21st Feb 2021, 7:17 PM
Imtiaz Faisal
Imtiaz Faisal - avatar
8 ответов
+ 4
Imtiaz Faisal You can try this: class Add { constructor(...words) { this.words = words; } //your code goes here print(){ var y =""; for(x of this.words){ if(x==","){ x =""; } else{ y+="
quot; + x } } y = y + "
quot;; console.log(y); } } 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();
22nd Feb 2021, 10:45 PM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
+ 3
class Add { constructor(...words) { this.words = words; this.print = print; } } function print() { var a = this.words.map((word) => "
quot;+word); var b = a.join(""); console.log(b+"
quot;); } 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();
22nd Feb 2021, 5:06 AM
SAN
SAN - avatar
0
move console.log(d); inside the method. return d; } } console.log(d); } }
21st Feb 2021, 10:04 PM
Bahhaⵣ
Bahhaⵣ - avatar
0
Thank you Bahha🐧 & @SAN!
22nd Feb 2021, 4:09 PM
Imtiaz Faisal
Imtiaz Faisal - avatar
0
Kkhiinadia755@gmail.com
1st Mar 2021, 5:54 PM
Amira Amora
Amira Amora - avatar
0
Amira Amora Is it you email Id?
2nd Mar 2021, 1:47 AM
❤️😍Prerana😍❤️
❤️😍Prerana😍❤️ - avatar
0
class Add { constructor(...words) { this.words = words; this.print=print; } //your code goes here } function print(){ console.log('
#x27;); for(let val of this.words) { console.log(val); console.log('
#x27;); } } 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();
2nd Aug 2022, 9:14 AM
Mohamed jihad
0
Thank you very much
19th Nov 2022, 8:01 AM
Artur Karapetyan
Artur Karapetyan - avatar