Some problems with the last exercise "Words" of the JavaScript course [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Some problems with the last exercise "Words" of the JavaScript course [SOLVED]

Hi there I have decided to write regarding a problem with the last exercise "Words" of the JavaScript course. I have correctly solved the last exercise "Words" of the JavaScript course but the system keeps giving me an error. Why? Help me please! I solved the exercise with different types of solutions (they are all strings), for example: $hehe$hoho$haha$hihi$huhu (with or without the $ at the end of the string and with or without " at the beginning and at the end of the string) $this$is$awesome (with or without the $ at the end of the string and with or without " at the beginning and at the end of the string) $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit (with or without the $ at the end of the string and with or without " at the beginning and at the end of the string) but none of these solutions are good. Why? This one is my code ( https://code.sololearn.com/cA35a10a2542 ): class Add { constructor(...words) { this.words = words; } //your code goes here print () { var l = new Array (); for (let i in this.words) { l.push("

quot;+this.words[i]); } //let m = (l.join("")); let m = (l.join("")+"
quot;); //let m = ('"'+l.join("")+"
quot;+'"'); console.log(m); } } 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(); I don't understand where I'm wrong. Thanks in advance to those who will help me.

9th Dec 2020, 1:51 PM
Alessandro Dari
Alessandro Dari - avatar
12 Answers
+ 4
Here goes ur code 😊 https://code.sololearn.com/cT8wMY2kNymt/?ref=app hope it helps if it really does mark it as verified answer plzz
9th Dec 2020, 1:54 PM
Aastha
Aastha - avatar
+ 3
@CarrieForle, @AJ #Learn With Me 👨‍💻 Unfortunately I had already tried in my code to remove the " " and add the $ to the end of my string, but the test gave me negative results, despite the fact that the result was the same as that of $ααρԋιɾє ☆☆☆, namely: $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ But thank you all anyway
9th Dec 2020, 10:38 PM
Alessandro Dari
Alessandro Dari - avatar
+ 2
Allesandro THANK you, it works! Thank you I have solved the task and get certificate of Javascript.
15th Dec 2020, 7:40 AM
Václav Dostál
Václav Dostál - avatar
+ 2
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();
8th Jan 2021, 11:10 AM
Vijayanathan Menakan
Vijayanathan Menakan - avatar
+ 1
Alessandro Dari No need of double quotes before and after the string. just do this let m = l.join('')+"
quot;;
9th Dec 2020, 2:16 PM
A͢J
A͢J - avatar
+ 1
Thank you so much $ααρԋιɾє ☆☆☆ Your code works very well! but I don't understand why your code works and mine doesn't 😊 Your result $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ is the same as mine (without " at the beginning and at the end of the string and with the $ at the end of the string) $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ Do you have an answer to that? muah...programming mysteries
9th Dec 2020, 10:25 PM
Alessandro Dari
Alessandro Dari - avatar
+ 1
class Add { constructor(...words) { this.words = words; } print(){ var t = ""; for( let v of this.words ){ t = t+"
quot; + v; } console .log (t+"
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();
28th May 2022, 3:33 AM
Nasser
Nasser - avatar
0
You don't need to quote the output text.
9th Dec 2020, 2:08 PM
你知道規則,我也是
你知道規則,我也是 - avatar
0
Allesandro, i tried your solution, but does not work.
14th Dec 2020, 5:24 PM
Václav Dostál
Václav Dostál - avatar
0
@Václav Dostál I know it, infact 5 days ago I wrote... << Thank you so much $ααρԋιɾє ☆☆☆ Your code( https://code.sololearn.com/cT8wMY2kNymt/?ref=app ) works very well! but I don't understand why your code works and mine( https://code.sololearn.com/cA35a10a2542 ) doesn't 😊 Your result $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ is the same as mine (without " at the beginning and at the end of the string and with the $ at the end of the string) $hehe$hoho$haha$hihi$huhu$ $this$is$awesome$ $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$ Do you have an answer to that? muah...programming mysteries >>
15th Dec 2020, 12:15 AM
Alessandro Dari
Alessandro Dari - avatar
0
How can you move quotation marks from a string? Is there a data type without them? OR are we returning an output identical to a variable name? I also wonder why there is a '$,
#x27; here: $lorem$ipsum$dolor$sit$amet$,$consectetur$adipiscing$elit$
3rd Jan 2021, 1:44 AM
Matthew Leroe
Matthew Leroe - avatar
0
Matthew Leroe Sorry, but I didn't understand your question.
3rd Jan 2021, 10:22 AM
Alessandro Dari
Alessandro Dari - avatar