6 kyu
Can you keep a secret?
14,696 of 14,713nmoadev
Loading description...
Fundamentals
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.
Forked to add a test to make sure no other sneakily-renamed properties are on the returned object, per the description
JS and CS: No sample tests
Good Kata. I understood what "method" to use almost right away, but wasnt able to make it work from the first time. It means I have to learn it better...
the basic test does not work, the solution was counted only after clicking on the "attempt" button
What's happening? I've got a "ReferenceError: console is not defined" like this:
Passed: 5 Failed: 0 Exit Code: 1
/runner/frameworks/javascript/display.js:55 console.log("\n<" + type.toUpperCase() + ":" + mode + ":" + label + ">" + msg); ^
ReferenceError: console is not defined at Object.write (/runner/frameworks/javascript/display.js:55:3) at Object.handleError (/runner/frameworks/javascript/cw-2.js:244:22) and etc...
This comment has been hidden.
Duplicate issue.
I'm sorry, but how to solve this issue? Couldn't find the answer
The same problem. How have you solved it?
It should be stated in the description that the returned object shouldn't have a key with the name of "secret".
This comment has been hidden.
Yeah, it's too easy for 6 kyu.
I'm sorry, but there are no tests for JavaScript version of this kata. Do we have to write it ourselves (which is frankly not as bad as it sounds, but still)?
Sample tests are not strictly necessary to complete a kata, and authors are not strictly required to add them. Sample tests can be meant as just an initially blank playground for users training on a kata, without any initial test cases.
However, it's considered a good authoring practice to provide a small set of sample tests, or, at least, replace the initial template with something at least a little bit meaningful and related to the kata.
Time: 617ms Passed: 5 Failed: 0 Exit Code: 7 timers.js:817 this.domain = process.domain; ^ ReferenceError: process is not defined
what could be wrong? tests all passed
I have the same issue.
This comment has been hidden.
I would recommend denoting this to 7 kyu. Just solved a couple of 8 kyus that were much harder.
Nice Kata. In addition to getSecret() and setSecret I also had a secret property. The error message I got was: "no property called 'secret'" It took me way to long to figure out I just needed to remove the secret property.
I feel something like: "There should be no secret property" would be much more effective.
Good suggestion. I'll fix that up.
@nmoadev You should add it to the description too.
Thank u. I spent a lot of time solving this problem
Thanks a lot! I didn't understand whats a problem, your comment helped me!
This comment has been hidden.
Same issue! How to fix it?
This comment has been hidden.
Duplicate issue.
Am I the only one who gets all tests to pass, but then gets a console.log is undefined error, preventing the test from succeeding?
I'm getting the same thing right now
Same. Cannot solve this.
Hey everyone, I added to the tests to help refine the acceptance criteria. There are now tests to make sure that multiple secret holders can be created and used. As well as that the secret is truly copied.
Is this not the same thing as a simple closure? I'm not sure how this would be useful in "real" code?
I can't say that it's super practical, however I think its worth knowing. It really just demonstrates an application of closures. But doing it correctly requires understanding javascript scoping pretty well.
Yeah... I think my problem is that you say "There's no such thing as private properties". But the "secret" variable here is effectively completely public anyway, making any secrecy or closure completely superfluous.
Ah, you mean because I make a setSecret() and getSecret() it doesn't demonstrate the value (if you have a setter and getter why not just have a property? Would you find the kata more interesting if getSecret() did something besides return the secret, like masked part of the secret (thinking about SSN's or something)?
I'll ponder a way to make it a more interesting application to demonstrate value. Good feedback.
Yeah, something like that. Don't let the user directly get or set the value; just let them influence it, or influence what comes out the other end.
Oh, I didn't realize I'm using closure, lol.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.