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.
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!
^^
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"]
.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
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).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
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...
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, actually. :]
Yes, my solution is very cool :]
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.
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!
Loading more items...