We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0597d65 commit 19f756eCopy full SHA for 19f756e
compare-version-numbers/index.ts
@@ -1,17 +1,18 @@
1
-export default function compareVersion(version1: string, version2: string): number {
2
-const a=version1.split(".").map(Number)
+export default function compareVersion(
+ version1: string,
3
+ version2: string,
4
+): number {
5
+ const a = version1.split(".").map(Number);
6
-const b=version2.split(".").map(Number)
7
+ const b = version2.split(".").map(Number);
8
-for(let i =0 ;i<Math.max(a.length,b.length);i++){
-
- const q=a[i]??0
9
10
- const w=b[i]??0
11
12
- if(q>w)return 1
13
- if(q<w)return -1
14
15
-}
16
-return 0
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
+ const q = a[i] ?? 0;
+
+ const w = b[i] ?? 0;
+ if (q > w) return 1;
+ if (q < w) return -1;
+ }
17
+ return 0;
18
}
0 commit comments