1
var thousandSeparator = function (n) {
2
let ans = "";
3

4
if (n >= 1000) {
5
const arr = String(n).split("");
6
for (let i = 0; i < arr.length; i++) {
7
let temp = arr.length - i;
8
if (
9
(temp === 3 && arr.length > temp) ||
10
(temp === 6 && arr.length > temp) ||
11
(temp === 9 && arr.length > temp) ||
12
(temp === 12 && arr.length > temp)
13
) {
14
ans += ".";
15
}
16
ans += arr[i];
17
}
18
} else {
19
ans += n;
20
}
21

22
return ans;
23
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0