This looks good to me. I tried to approve it but for some reason I get a 401 Unauthorized response when I click the "Approve" button.
I have ported the original closely, but I avoided the use of the solution code in the test, since this is a bad practice.
Thanks for the feedback! I've added the random test, and added a basic test as well that closely matches the original example.
This is not ideal, since it will return NULL if the value is not numeric. This puts the responsibility to check the return value on the calling code. A good solution would be to throw an exception if $n is not numeric.
NULL
$n
Loading collection data...
This looks good to me. I tried to approve it but for some reason I get a 401 Unauthorized response when I click the "Approve" button.
I have ported the original closely, but I avoided the use of the solution code in the test, since this is a bad practice.
Thanks for the feedback! I've added the random test, and added a basic test as well that closely matches the original example.
This is not ideal, since it will return
NULL
if the value is not numeric. This puts the responsibility to check the return value on the calling code. A good solution would be to throw an exception if$n
is not numeric.