Draft
Roman numeral decoder with format validator
35RaRaton
Loading description...
Algorithms
Parsing
Strings
Regular Expressions
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.
missing invalid tests:
no random tests
@Johan: what the HELL are you doing!??
This is a trivial duplicate.
Great kata! And solid explanation, too; I've had so much trouble trying to figure out the ins and outs of this format while trying other katas. I even used this explanation to solve the linked validation kata!
Missing test for empty string. Also, missing random tests.
Hi! Thanks for the review. I added a test for empty string. I don't get why I need to add a radom tests? I included some non-well and well formatted roman numerals inside of test cases. Test cases should be as simple as possible, so these are easy to verify and correct. I don't see the advance of aleatory number a part of If I test all the possible cases. Could you please be more specific? I am still learning TDD. Thanks!
Random tests guard against someone just enumerating correct answers, instead of really solving the kata.
Did you see my second solution? No Roman numeral in sight there, yet it passes. This is impossible with random tests.
In short, it prevents cheating.
Yes, my solution is very cool :]
It is, actually. :]
Ok, I see your point now, thanks. But, I have troubles to understand your code. I am newbie with javascript. Please, Could you tell me what is the functionality of => operator? I searched in W3School web and google, but, I couldn't find it. Where is v variable coming from? If you can share any reference or web page, I would look up it by myself. I want to undersand your code, because I think I would learn, Many thanks! :D
It is an anonymous function. An example will help
The only thing that is different is the context of this inside an arrow function otherwise it's just like an ordinary function :) hope that helps...
See MDN
"function" functions can also be anonymous; that's not the difference. It's just a different, shorter syntax with some restrictions and limitations.
The following examples are all more or less equivalent
And functions of zero arguments are possible in both syntax variations. (In this case, you cannot leave out the parentheses with the fat arrow syntax. You'd have nothing left. :)
You could then use
pi()
for3.14
. It's sort of a constant, if it doesn't reference outside state (which my solution does! so it's not a constant anymore).Thanks to all of you for these useful comments!! OMG!! I would never have found out by myself!! JohanWiltink, I am not able to see the last line of your solution. I think it's incomplete. I try to understand this last line. Is [...s] another type of sort code trick? Thanks again :D
Yes, if you click on View Solution you're not getting everything. I guess it's a bug, or maybe a feature, of CodeWars. You can look up the full source on the solutions page.
[...s]
is shorthand fors.split("")
(wheres
is a string) using the spread operator. I can't find a decent MDN reference for this, but[..."abc"] === ["a","b","c"]
.^^
Part duplicate of https://www.codewars.com/kata/roman-numerals-decoder/javascript
I will add a note to this kata.
There's one kata in beta about validation of roman format.
Perhaps it would be good idea to link it in description, as it'll translate fully to one of your functions required in kata :)
Link to kata:
https://www.codewars.com/kata/58334362c5637ad0bb0001c2
Really enjoyable kata, well done!
Thanks gabbek! I have included a note in the description of my kata :D