6 kyu
Implementing Object.create
2,352moorsiek
Loading description...
Fundamentals
Object-oriented Programming
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This comment has been hidden.
JS version update
approved
There are no tests with functions as prototype. So solutions which just check that
typeof proto === 'object'
pass.In the Information section, I think, there is some confusion between literals and primitives. A
String
literal like'abc'
is a primitive, and cannot be passed toObject.create()
. But this is also true of any string variable, i.e. any variable whosetypeof
returns'string'
:let str = String();
is also a string primitive and similarly cannot be used as a Prototype, despite the absence of a string literal in its definition.In modern JavaScript,
__proto__
is deprecated, and programmers are encouraged to useObject.set/getPrototypeOf()
insteadwas before es6
it was still an issue, the point is to teach current best practices
This kata doesn't work with Node v10.x. Everything is either null or undefined.
are you sure ? I just passed it using Node v10.x
seems to work now.
This note in the kata description is incorrect:
NaN and Infinity are numbers and therefore primitive values. They cannot be passed as the prototype into the native Object.create().
Thanks for that, you right! I've updated the Kata. Back then I possibly fooled myself, because NaN and Infinity is autoboxed into a Number without the need of () or space after
1.
<- dot.Approved
I also fixed a test case where it would fail on Node 6 + Babel version.
Trying to submit the code throws "Object # has no method 'log'" error.
Unclear, closing.
When submitting my solution I get the error below. I have tested the solution in jsfiddle and it worked fine. Any ideas what's wrong?
default tests are confusing
In the example test fixture, what you currently have (as follows) is invalid code:
Try:
Hrm... it works fine. But you pretty much told us exactly how to implement it. Almost line-by-line. Kinda takes all the fun and challenge out of it, I feel.
If anybody used a code snippet from the kata's description and had troubles with passing tests based on it — my big apologies!! There was a stupid bug, my fault. It could confuse warriors because gave wrong results, when the solution is actually ok. I've updated it and now it's ok! I'm the evil, undoubtedly! ]:-> And my big thanks to trymedo and westvud for discovering that thing! Well done guys! :)
This is my first kata, so there could be some unexploded ordnance in the kata. Any feedback is welcome :)
This looks great—nicely done!
Only small thing I noticed was when I copied the example from the brief. There's a missing closing bracket in the veteran object.
var veteran = Object.create(citizen, {panic: function(){ return "SNAFU"; } } // Here );
Just a heads up. Otherwise, it's good! I haven't quite cracked the full solution yet, but that's my fault! :(
Thanks, guys! And GJ, trymedo :)