How could it be possible to print ($...$)? If you want to explain.. then please help Sololearners friends! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How could it be possible to print ($...$)? If you want to explain.. then please help Sololearners friends!

Usually, as we know that `${expression}` according to ES6.. to print out without any "" comma.. even except the '+' sign ... Then how could it be print $ sign at the beginning of the corresponding word.. ? It can be at finishing part of the word.. then? class Add { constructor(...words) { this.words = words; } //your code goes here print(){ var y ="

quot;; for(let x of this.words){ y += `${x} ; } 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();

20th Feb 2023, 5:35 AM
Sony
Sony - avatar
5 Answers
+ 1
In case you're wondering where the first '
#x27; came from; look in print() method. There variable <y> is initialized with a '
#x27; and each element of array <words> is accumulated in <y> with a '
#x27; on its end.
20th Feb 2023, 12:25 PM
Ipang
+ 1
Code works without any issue, then I'm not sure what the problem is. The output already have the $ in the beginning, in between, and at the end of the output string. What was your doubt again?
20th Feb 2023, 10:25 AM
Ipang
+ 1
then how can it be $ sign in both sides? `${expression} . The sign should be visible from the finishing part of the output not the beginning.. because that is the default method l ... Which is set previously... Thanks!
20th Feb 2023, 12:12 PM
Sony
Sony - avatar
+ 1
Ipang It's my fault to get it on.. just got into the dilemma.. thank you so much to help me to catch up the point.. I just forgot to assume the $ initialization with y variable.. thanks ..
20th Feb 2023, 12:33 PM
Sony
Sony - avatar
0
as per method what we do actually? console.log(`The name of the flower is ${expression}`);
20th Feb 2023, 12:10 PM
Sony
Sony - avatar