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.
this doesn't pass all the time,
This comment is hidden because it contains spoiler information about the solution
Why is the correct answer 1 in this test? because the element with index 2 is less than 'n'
Test.assertSimilar(howManySmaller([1.1888,1.1868,1.1838],1.19), 1);
Thanks! I will try another solution
Not with null, no.
as I understand it, in this example, you cannot use a loop for
Any line where you use
length
without properly checking if it is an array before.tell me which line is the error. when you click on the test, the result is correct. attempt length error.
One of the tested inputs is
null
. Your function needs to be able to handle it, but as you have it written now, the function fails because you try to find the length ofnull
.how. in the loop we go through the array and the length is set there correctly, as I understand it. further, if the value is greater than the lesser and less than the greater, we add it to the variable sum. I don't understand where the error is, I'm a beginner developer.
Read the error message:
TypeError: Cannot read property 'length' of null
it's not the length what is null, it's the value passed to your function, andnull
has no length.This comment is hidden because it contains spoiler information about the solution