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 comment is hidden because it contains spoiler information about the solution
If you mean the sample tests, you need to write your own, otherwise, click Attempt directly.
I looked at the solution and when I copied and pasted this-it didn't work for me.
I have no idea why not.
So Javascript just wants to join in on the OOP club?
As far as i know, because this one is still considered as an object, where you can directly write function rather than declaring 'class' first, it is also known as Constructor Function.
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
This comment is hidden because it contains spoiler information about the solution
I'm not disagreeing with you because I'm still learning JS, but as a programmer that seems wrong to me. Since you can't confirm what type the input will be, wouldn't it be best to check against undefined rather than your method? I mean again, it's clever - but would you really want to use it in production? Is it faster to make sure the input isn't falsy, AND use the code above?
This comment is hidden because it contains spoiler information about the solution
Very clever, but is this a best practice? It's not immediately clear what's going on, whereas the other solutions are.
it is not a good idea to make
func
its own context. Betterthis
, so the function context can be set by callingspread
in whatever context you choose.I'm sure you are all right. JS is very confusing at times. A function can not hold a variabel that 'this' can access right? An object (called through the this keyword) can access it's properties via dot-, or bracket notation. Then what's the point of using a function as the object as you have no use for the 'this'?
Loading more items...