For "real world use", I think a string without an hash should be tested as well: check('www.codewars.com', 'www.codewars.com')
check('www.codewars.com', 'www.codewars.com')
This comment is hidden because it contains spoiler information about the solution
You are supposed to write yourself all the solutions
It has nothing to do with having to write everything from scratch.
ROTFL!
Crazy initialization by 9007199254740992 ... 😆
val +=
val = val + ...
val += val
val
val > 1
I usually use brackets for better readability:
val += (val > 1) ? ' ' + key + 's' : ' ' + key
If you use a template string, you could write it like so:
val = `${val} ${key}${(val > 1) ? 's' : ''}`
Hope I didn't code it wrong ;)
I like this solution. Few and performant code! Well done.
I like it. Nevertheless one should notice that substr() is marked as deprecated: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
For "real world use", I think a string without an hash should be tested as well:
check('www.codewars.com', 'www.codewars.com')
This comment is hidden because it contains spoiler information about the solution
It has nothing to do with having to write everything from scratch.
ROTFL!
This comment is hidden because it contains spoiler information about the solution
Crazy initialization by 9007199254740992 ... 😆
val +=
you could also writeval = val + ...
val += val
. The secondval
doesn't belong to the first one. It belongs to the comparisonval > 1
.I usually use brackets for better readability:
If you use a template string, you could write it like so:
Hope I didn't code it wrong ;)
I like this solution. Few and performant code! Well done.
I like it.
Nevertheless one should notice that substr() is marked as deprecated:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr