+ 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();8 Antworten
+ 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();
+ 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();
0
move console.log(d); inside the method.
return d;
}
}
console.log(d);
}
}
0
Thank you Bahha🐧 & @SAN!
0
Kkhiinadia755@gmail.com
0
Amira Amora
Is it you email Id?
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();
0
Thank you very much