7 kyu
Default + Rest + Spread
672matt c
Loading description...
Refactoring
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.
Fixed tests allow my solution, where
Rest
is, I think, not what was intended, but works because the tests happen to work for it.No random tests.
Fixed tests are overly limited, simplistic, and pass correct solutions instead of trying to break incorrect ones.
defaultExample(3,7) -> 10
should have any argument but7
in second place.restExample
should have tests with the second argument not accidentally always the correct length.spreadExample(...[1,2,3])
is literally justspreadExample(1,2,3)
( except less efficient ). Those tests should have a varying number of arguments.Description's block code markdown is broken.
ES6 makes my life easier.
Good Kata :) Instructions are simple and unambiguous. (Kata) Requires a tiny bit of thinking.
I personally think this Kata is ready for approval and that it should be ranked as 7kyu.
Thank you, just needs a moderators approval now :)
Good Kata! I have noticed some people are cheating on the rest parameters, just filling in 'x,y,z' as per the test cases; it might be better to use some variation on test cases so people can't directly use that cheat (and they would have to use a lot more code if they want to filter out the amount of arguments, OR use rest parameters).
Nice educational kata! One suggestion: the convention in JavaScript is to use lowerCamelCase for variable and function names, so
Default
,Rest
, andSpread
should bedefault
,rest
, andspread
. You use lowerCamelCase in the examples, but UpperCamelCase in the actual code, which is odd.The reason for that is in javascript you can't use default as a function e.g.
will throw an error because default is a keyword used in switch/case statements so I thought I'll keep them all the same if that's okay?
(Didn't mean to resolve if you had another idea)
I suggest naming them defaultExample, restExample, and spreadExample, and then you can also add the code:
above your test cases so that you don't invalidate any of the existing correct solutions (if you care about that, which you don't necessarily need to).
That causes a Reference error for solutions that use the old method names
You're right, here's the correct code:
I've gone ahead and made the change as a contributor. I hope that's not stepping on your toes. If you don't like the change, just let me know and I'll change it back to the original version.
That's all fine, thanks for your input. We're here to help the community anyway :)
Well, I thought it was a really great and useful kata, so I wanted to help!
Like other comments, I found the description a little too vague - I think it needs to be super clear (preferably before the theory explanation) that the aim is to alter the function bodies to pass the existing tests.
Mainly because this type of exercise is a little different to just about every other kata which has a defined goal and the test cases are just used to verify the goal, rather than the test cases being the goal itself.
I did like the explanation of the ES6 features though so well done!
I'll just make it a refactoring kata then it should be fine.. because honestly I don't know what else to put there if you could give an example of what you want to see?
I've made some changes if you would like to review them?
This comment has been hidden.
I've changed the kata to a refactoring kata which now I think the descriptions describes fine? If you could have a quick read and mark this solution as solved if you believe it's ok?
This comment has been hidden.
Whoopps! Forgot to remove that, I've changed the Rest function and I had the same problem thinking of the better Spread function example :)
All good, thanks for taking the time to incorporate my feedback.
Thank you for feeding back :)
expected value from second test case from "Rest" is correct?
yes for example if you had a function like this
This is because
a = 1, b = 2
but the rest of the arguments are concatenated into an array soc = [3, 4, 5]
. since the return statement is(a + b) * c.length
it basically stands for(1 + 2) * 3
hence the answer as 9. Hope this makes sence, good luckThere still is a missing
{
in the start of the Spread function.Very sorry, thought I fixed it, Please mark issue as resolved if I have.
I'm marking as resolved because I believe I've fixed the issue and you haven't changed issue status in 3 weeks, thanks :)
Very sorry. I must have missed your answer.
Good that you decided to mark it as resolved yourself! :-)
This kata needs a much better description, and/or better setup code.
Yes it deffinitly does, I will update it as soon as I can. Sorry I missed it
Please mark this issue as resolved if you think the description is better, and if you believe the setup code could be better could you post an example, thank you!
You could either explain what each function is supposed to do or, if part of the challenge is to figure that out, at the end of the description say: "Using the indicated feature, implement a function that achieves the following results:" Then copy the test cases into the description.
Also
Spread
needs a{
.have I not done that?
The directive to "complete the three functions" seems vague to me. Once I begin the kata, I can infer from the default test cases what the functions should do, but from the description I don't get a very clear picture of what the problem is and what I need to do to solve it.
I do not see how someone could not understand that, I'm sorry there are plenty examples of how it's done and the test cases can be refered to if they are suck...
Is reverse engineering the requirements part of this kata?
The requirement of the kata is to complete the test cases, it is also an oppertunity to follow the new features of ES6 javascript which will help solve this kata easier, lots of examples in the description.