Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
[javascript]. My code is getting failed test cases when they should be passing. For example, I get this error message:
should work for random perfect powers
your pair (40, 6) doesn't work for 4097152081 - Expected: 4097152081, instead got: 4096000000
when in fact Math.pow(40, 6) = 4096000000. And also:
should return valid pairs for random inputs
your pair (33, 3) doesn't work for 35947 - Expected: 35947, instead got: 35937
but again Math.pow(33, 3) = 35937
I'm doing this kata in Javascript. My code is getting failed test cases when they should be passing. For example, I get this error message:
should work for random perfect powers
your pair (40, 6) doesn't work for 4097152081 - Expected: 4097152081, instead got: 4096000000
when in fact Math.pow(40, 6) = 4096000000. And also:
should return valid pairs for random inputs
your pair (33, 3) doesn't work for 35947 - Expected: 35947, instead got: 35937
but again Math.pow(33, 3) = 35937
http://stackoverflow.com/questions/7310109/whats-the-difference-between-and-in-javascript
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Here's my code:
function sumArray(array) {
if (array === null || array.length == 0 || array.length == 1)
return 0;
return array.sort(function(a,b){return a-b}).slice(1, -1).reduce(function(a,b){return a+b});
}
When submitted, I get 3 passed tests and one error saying "TypeError: Reduce of empty array with no initial value at Array.reduce at sumArray". Why am I getting this error?