I appreciate the desire for a single exit point, but seems unnecessary in this situation.
Here's a version that's much easier to read based on the CodeWars discussion with the additional feature of handling mismatched lengths:
function higherVersion(ver1, ver2) { ver1 = ver1.split('.').map(Number); ver2 = ver2.split('.').map(Number); const limit = Math.min(ver1.length, ver2.length); for (let i = 0; i < limit; i++) if (ver1[i] !== ver2[i]) return ver1[i] > ver2[i]; return ver1.length > ver2.length; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I appreciate the desire for a single exit point, but seems unnecessary in this situation.
Here's a version that's much easier to read based on the CodeWars discussion with the additional feature of handling mismatched lengths: