javascript
compareVersion(version1, version2) {
let v1 = version1.split('.').map(m => parseInt(m));
let v2 = version2.split('.').map(m => parseInt(m));
for (let i = 0; i < v1.length && i < v2.length; i++) {
if (v1[i] < v2[i]) return -1;
if (v1[i] > v2[i]) return 1;
}
if (v1.length < v2.length) return -1;
if (v1.length > v2.length) return 1;
return 0;
}