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 comment is hidden because it contains spoiler information about the solution
This solution is attempting to use duck-typing, however it is a problematic approach because the
length
property could be added to anObject
.This solution is attempting to use duck-typing, however it is a problematic approach because the
length
property could be added to anObject
.On top of that, you are using an if/else statement, when you could just
return value.hasOwnProperty('length')
(even though hasOwnProperty is not the best approach).This solution is attempting to use duck-typing, however it is a problematic approach because the
length
property could be added to anObject
.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Except that the description says to append "..." to the returned string, so you would have to check that limit+3 === returnValue.length.
I just tried to submit my solution and it failed me because it says
solution("Test", 10) did not return "Test"
even though my code was correct as described by the instructions.Dropping curly braces in JavaScript is a bad practice. It can lead to unexpected behavior due to JavaScript auto-semicolon-insertion feature.
Consider the following:
Dropping curly braces in JavaScript is a bad practice. It can lead to unexpected behavior due to JavaScript auto-semicolon-insertion feature.
Consider the following:
Define the toString method by assigning it to the constructor's prototype.
It's better to throw an error here than assign empty strings if the right parameters are not given. How will you debug code like this?
Completely unmaintainable.
Why?
The other downside is that assigning the toString method here means that every time a new Animal is constructed, the toString method needs to be assigned. The drawbacks here are
This solution should be considered "incorrect".
Loading more items...