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.
[]
is a more primitive way of accessing all kind of arrays.charAt()
is specific to strings.You can access the index of any array by using
[]
, but you can only usecharAt()
on a string.But when it comes to string alone, both are one and the same.
But you should use
charAt()
because, it is well supported in all the major browsers, while the bracket notation will returnundefined
in IE7Also, the bracket notation is simply accessed, while
charAt()
does some validation and doesn't returnundefined
, but will return an empty string""
Sources:
https://stackoverflow.com/a/22728925
https://stackoverflow.com/a/5943760
https://blog.vjeux.com/2009/javascript/dangerous-bracket-notation-for-strings.html
https://stackoverflow.com/a/5943807
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#character_access
i wanted to give it clever but i dont wanna rune this master pices
POV : ^ Clever 69
I really like this answer. Very clean.
I also like this one. Using a named function is more descriptive.
Very clean! I recommend moving
capitalizeFirstLetter
outside of function for reusability