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.
From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce:
The initial value is like a backup value for when it's empty/only one item or there's a NaN value at index 0. Since reduce works by looking at index 0, if there's nothing there it returns an error.
cool thanks!
Why does it need a starting value of 0? it already starts at 0 doesn't it?
is the same as
array !== []
is true. This means it will try to sort the null value; leading to an error.typeof(null) = "object"
You are doing
if typeof(null) == "null"
and therefore the code fails. You should directly compare a null and not use a type comparison. The null value has not been 'caught' and then it tries to read the length of this value, which produces this error.This comment is hidden because it contains spoiler information about the solution
What language are you having the issue in?
This comment is hidden because it contains spoiler information about the solution
You have to check first for null and then access the array. ;-)
"var highest = array[0];" is the first access....
This comment is hidden because it contains spoiler information about the solution