+ 4
Wrong test "Words" in JavaScript.
What should be the result of the text? $word1$word2$word3 or $word1$word2$word3$
15 ответов
+ 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.
+ 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();
+ 4
Tet is actually broken. But it can be passed. Just remove the comma from the list.
+ 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(
+ 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.
+ 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();
+ 1
The test doesn't work.
https://code.sololearn.com/WqNtJAz2Ts2K/?ref=app
+ 1
Ok, thanks.
+ 1
Shadow, thanks!
+ 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
+ 1
maybe also this thread can help
https://www.sololearn.com/Discuss/2620022/?ref=app
- 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