+ 5

May I know what's wrong with the answer???

every word in the string must be printed with dollar sign https://code.sololearn.com/W34EeghYpW1O/?ref=app

26th Dec 2020, 6:09 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
12 Respuestas
+ 3
yeah, now that's ok. really simple.
26th Dec 2020, 11:47 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
+ 2
You are probably trying to complete the javascript exercise. You must do it in your own. Tip: Store the complete text in a variable and output it using console.log instead of document.write at the end.
26th Dec 2020, 6:16 AM
Art1mis
+ 2
Thank you so much!
26th Dec 2020, 11:06 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
+ 1
But it doesn't ok if I use 'console.log(). I
26th Dec 2020, 6:23 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
+ 1
Wah Wah Shwe I have suggested console.log because I thought you are trying to complete the exercise. If you are doing something else then please tell? Note: you have to implement the logic yourself, like this question. https://www.sololearn.com/Discuss/2640770/?ref=app
26th Dec 2020, 6:28 AM
Art1mis
0
Here is my code! help me why it doesn't work. /*HETE IS THE PROBLEM You are making a text encryptor. It should take multiple words and output a combined version, where each word is separated by a dollar sign $. For example, for the words "hello", "how", "are", "you", the output should be "$hello$how$are$you
quot;. The given code declares a class named Add, with a constructor that takes one rest parameter. Complete the code by adding a print() method to the class, which should generate the requested output.*/ class Add { constructor(...words) { this.words = words; } //your code goes here print() { for (let k = 0; k<this.words.length; k++) { document.write("
quot;+this.words[k]); } document.write("
quot;); document.write("\n"); } } 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 Dec 2020, 6:32 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
0
What is the problem? Do you want it to print to DOM or what? print(){ var p=""; for (let i=0;i<this.words.length ;i++){ p = p + "
quot; + this.words[i]; } let r=p+"
quot;; console.log(r) } or print(){ console.log('
#x27;+this.words.join('
#x27;)+'
#x27;) }
26th Dec 2020, 6:36 AM
Art1mis
0
That's OK when I check this code with IDE. But why??? I can't solve the problem?
26th Dec 2020, 6:44 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
0
Wah Wah Shwe Do let me know what is the actual problem?
26th Dec 2020, 7:06 AM
Art1mis
0
The test case is hidden and so I can't explain. Thank you so much any way!
26th Dec 2020, 7:38 AM
Wah Wah Shwe(와와쵀)
Wah Wah Shwe(와와쵀) - avatar
0
Wah Wah Shwe It's against community rules to ask for your homework. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community However, I have already given you the answer. Just paste print method I have shared earlier in your Add class and it will pass the test. Further, your input in var z seems to be wrong. (Line 19: There is one "," extra input) Reset the code and try again or copy & paste this code. ☺ https://code.sololearn.com/cZdFvYpR2O91/?ref=app
26th Dec 2020, 7:41 AM
Art1mis
26th Dec 2020, 11:45 AM
Brian
Brian - avatar