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.
Thanks for the tips @CrazyMerlyn. Finally got it :)
When there is no match in a string, the
match
function returns null.Since
null
doesn't have the length property, your code throws the error when the string has no non-whitespace characters. Note that your check only works for empty strings, not for strings which constitute entirely of spaces.This comment is hidden because it contains spoiler information about the solution