+ 4

Wrong test "Words" in JavaScript.

What should be the result of the text? $word1$word2$word3 or $word1$word2$word3$

7th Dec 2020, 7:15 PM
Николай
Николай - avatar
12 Respostas
+ 2
There needs to be a dollar sign both at the start and the end of each line, like in your second example. The comma in the third string should just be treated like any other word in the array.
7th Dec 2020, 7:55 PM
Shadow
Shadow - avatar
+ 6
This is a working example: class Add { constructor(...words) { this.words = words; } print() { console.log("
quot; + this.words.join("
quot;) + "
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();
9th Jan 2021, 5:17 PM
Professional Anonyme
Professional Anonyme - avatar
+ 4
Tet is actually broken. But it can be passed. Just remove the comma from the list.
21st Dec 2020, 8:25 PM
Professional Anonyme
Professional Anonyme - avatar
+ 2
I tried with "
quot; at the end and without. I tried to process "," with and without $ in different ways. And completely deleted ",". I don't understand what the test needs(
7th Dec 2020, 7:35 PM
Николай
Николай - avatar
+ 2
Hm, the example given in the description is still wrong. So if there was an issue with solutions, lets hope the task gets a small overhaul as well. I've noticed a number of questions regarding this specific one over the last days. Anyway, I'm glad it worked out for you now.
7th Dec 2020, 8:28 PM
Shadow
Shadow - 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:09 AM
Vijayanathan Menakan
Vijayanathan Menakan - avatar
7th Dec 2020, 7:25 PM
Николай
Николай - avatar
+ 1
Ok, thanks.
7th Dec 2020, 7:29 PM
Николай
Николай - avatar
+ 1
Shadow, thanks!
7th Dec 2020, 8:16 PM
Николай
Николай - avatar
+ 1
Already working! https://code.sololearn.com/WYwBjEomdD8V/?ref=app Apparently the app developers corrected it)) Because it didn't work before: https://www.sololearn.com/Discuss/2611466/?ref=app
7th Dec 2020, 8:19 PM
Николай
Николай - avatar
+ 1
10th Dec 2020, 9:04 PM
Alessandro Dari
Alessandro Dari - avatar
- 1
My code is quite simple but it is working just fine. class Add { constructor(...words) { this.words = words; } print() { const wordsWithDolars = this.words.map(word=>`${word} ); const reducedWordsWithDolars = wordsWithDolars.reduce((acc,currentValue)=>acc+currentValue,'
#x27;); console.log(reducedWordsWithDolars); } } 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();L
11th Jan 2021, 8:40 PM
Tomasz Zarankiewicz
Tomasz Zarankiewicz - avatar