We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I'm using Javascript and for me it's saying my output is correct, but it's not letting me move on because of a runtime error on line 47 with result.join being undefined.
same here. I kept losing my cool, thinking I did something wrong. I tried multiple solutions, arrived at the correct output 3 -way times, but getting a runtime error with result.join as you say. Same for python. LAME!
Is your function returning a string? If so, this is the issue. The join method expects an array, so you want to be returning something in the format [aScore, bScore].
Then, result.join will convert the array into the expected output format.
This at least worked for me, hope my explanation is of some use to you
I got a same error so I tried to return array. Then it fixed.
var result = [];
var aScore = 0,
bScore = 0;
for (var i = 0; i < a.length; i++) {
if (a[i] > b[i]) aScore++;
if (a[i] < b[i]) bScore++;
}
result[0] = aScore;
result[1] = bScore;
return result;
You have built the best script from python which is every difficult programming. But still it's failing in the execution process, which is the saddest thing. I have been trying to write a papersowl reviews article on this code based upon your articles. And trying to make a good script to make own website. I hope it turns well.
Compare the Triplets
You are viewing a single comment's thread. Return to all comments →
I'm using Javascript and for me it's saying my output is correct, but it's not letting me move on because of a runtime error on line 47 with result.join being undefined.
Same problem here!
Same here :(
same here. I kept losing my cool, thinking I did something wrong. I tried multiple solutions, arrived at the correct output 3 -way times, but getting a runtime error with result.join as you say. Same for python. LAME!
If you are using JS, just do it. Change the line 55 for "ws.write(result += "\n");"
I'm having same problem. The code works for my test cases, but does not let me submit due to error of "join" not being recognized.
Victorviannaribe1 your solution doesnt work. Tenta de novo
Is your function returning a string? If so, this is the issue. The join method expects an array, so you want to be returning something in the format [aScore, bScore].
Then, result.join will convert the array into the expected output format.
This at least worked for me, hope my explanation is of some use to you
I got a same error so I tried to return array. Then it fixed.
var a = [a0, a1, a2]; var b = [b0, b1, b2]; var ascore = 0; var bscore = 0;
function compareTriplets(a0, a1, a2, b0, b1, b2) { var resultsArray = [];
for (var i = 0; i < a.length; i ++) {
} resultsArray[0] = ascore; resultsArray[1] = bscore; return (ascore + "" + bscore) }
Wow! It really helped dude. Thank you.
i have same problem, returned array done thank you
You have built the best script from python which is every difficult programming. But still it's failing in the execution process, which is the saddest thing. I have been trying to write a papersowl reviews article on this code based upon your articles. And trying to make a good script to make own website. I hope it turns well.
Yea if you chose the JavaScript (nodejs) template for the response, the solve method expects you to return an array.
[scoreAlice scoreBob]
But tbh you should be able to figure that out by reading the error ;) Good luck.
Same problem here
edit the original code to
ws.write(result + '\n');
and run again
add .("")