loading...

re: JavaScript Katas: Higher Version VIEW POST

TOP OF THREAD FULL DISCUSSION
re: A little abstraction goes a long way to improving this answer. const toVersion = (string) => string.split('.').map(Number); const orderVersi...
 

There's a issue with your code, but what if I use this?

higherVersion("1.2.3", "1.2.3");
// ???

higherVersion("9", "9");
// ???
 

Adjust the partition if you want to exclude the equal case.

const higherVersion = (string1, string2) =>
  orderVersions(toVersion(string1), toVersion(string2)) > 0;

This is the best response from the rest. (👍)

Alt text

The nice thing is that it should also allow you to sort an arbitrary number of versions.

Code of Conduct Report abuse