Please can I get some help regarding the 'Words' Code Project that comes after the module 8 quiz in theSololearnJavaScriptcourse | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 2

Please can I get some help regarding the 'Words' Code Project that comes after the module 8 quiz in theSololearnJavaScriptcourse

When the code outputs the words it does what the instruction says that is the $ sign should be printed along with the word that is to the left and right of the word but it does not print it in a horizontal line like it would in an array (except for the bracket and the commas) can someone help with this please, I am done with the course and it is left with that project. class Add { constructor(...words) { this.words = words; } //your code goes here print(){ var p=0; var q=this.words.length; for (var r=0;r<q;r++){ p++; console.log("

quot;+this.words[p]+"
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();

26th Sep 2021, 12:40 PM
David Osam
David Osam - avatar
11 Respuestas
+ 4
If you want you can see that, but better will be when you think about another solution again. Otherwise David Osam please analyse carefully this code: https://code.sololearn.com/WEw96E0lsJh4/?ref=app
26th Sep 2021, 4:13 PM
JaScript
JaScript - avatar
+ 4
A hint : for example, for the words "hello", "how", "are", "you", the output should be "$hello$how$are$you
quot;. And without new line for each word.
26th Sep 2021, 12:55 PM
JaScript
JaScript - avatar
+ 3
That is what I'm struggling with so can I get a clear understanding of what I should do
26th Sep 2021, 3:01 PM
David Osam
David Osam - avatar
+ 2
Wait a sec
26th Sep 2021, 2:47 PM
David Osam
David Osam - avatar
+ 2
You're right but that's exactly the issue I'm facing. I haven't been able to do that
26th Sep 2021, 2:48 PM
David Osam
David Osam - avatar
+ 2
I'll send a code snippet soon demonstrating how I can get all to be printed to the console on one line when the function is called. Unfortunately with this method the output has a $ to the left and right of the whole line instead of for the individual words
26th Sep 2021, 2:51 PM
David Osam
David Osam - avatar
26th Sep 2021, 2:56 PM
David Osam
David Osam - avatar
+ 2
Alright, there it is. So the goal is to print the words with the $ to the left and to the right of each word and also have all the words for that string printed to the console not on new lines when the function is called
26th Sep 2021, 3:00 PM
David Osam
David Osam - avatar
+ 2
Woa I owe you one! How did you get that? It would not have occurred to me at all. Thanks a lot. An example like the Words project should be put in one of the JavaScript lessons to guide someone like me next time
26th Sep 2021, 6:38 PM
David Osam
David Osam - avatar
+ 1
Another happy customer
27th Sep 2021, 9:44 PM
D L J Hearn
D L J Hearn - avatar
+ 1
Yeah. Would have taken me ages to realize that. I'm done with the entire course now so I'll take my time and revisit some of the topics since it's evident that I need more practice
28th Sep 2021, 12:47 AM
David Osam
David Osam - avatar