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 solution may not be the most intuitive for beginners, but it is the best you can do.
This is indeed a Constructor function.
return this
is implicit.So Javascript just wants to join in on the OOP club?
so, try to test
[1,2].sameStructureAs([[3],3])
beautiful solution
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 kata is created before JavaScript has
class
. On those days, we use this function constructor to simulate aclass
.Fun fact: JavaScript actually doesn't have a
class
, theclass
is just a syntatic sugar on top ofprototypes
.Nice, I tried to do something similar. Unnecesary generalization ftw
Why the result is set to 'this.ballType' instead of 'return'ing?
The kata asks to create a class. Is this also considered a class? Looks like a function.
//[ 1, [ 1, 1 ] ].sameStructureAs( [ [2], [ 2, 2 ] ] )
For this, your algorithm will return true instead of false
lazy!
[1,1,[1],1].sameStructureAs([1,1,[1],[]]) // true
This comment is hidden because it contains spoiler information about the solution
4 years later and it's still here unfortunately.
Loading more items...