+ 1
Please guy's what is missing in my rest parameters code problem (...words)
class Add { constructor(...words) { this.words = words; } print() {console.log(this.words ); } } var x = new Add("$hehe
quot;, "$hohoquot;, "$hahaquot;, "$hihiquot;, "$huhuquot;); var y = new Add("$thisquot;, "$isquot;, "$awesomequot;); var z = new Add("$loremquot;, "$ipsumquot;, "$dolorquot;, "$sitquot;, "$ametquot;, "$consecteturquot;, "$adipiscingquot;, "$elitquot;); x.print(); y.print(); z.print();7 Réponses
+ 2
Noibisjunior
join() function used to combine multiple words.
join() function takes one parameter and it can be any separator like any symbol ($, #, @) anything.
So in this practice you have to join words with $ so in print function just do this:
console.log("quot; + (this.words).join("quot;) + "quot;);
+ 1
Noibisjunior
Don't change anything in given code. Just change in print function. You have to add $ between words and start of the word and end of the word.
So for this you can use join () function and to add before and after the word just concat $.
+ 1
My expected output is to print multiple words joined with the dollar sign ($)
Though I have already solved the code problem.
0
Noibisjunior
Where is your attempts?
0
I tried using the print function to output the string altogether but it output is in different arrays
0
AJ
Which means am using two function join() print ()
Really need more explanation
0
What is your current output , and what would you like to print?