Skip to content

Commit

Permalink
perf: replace array.form with for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsd committed Oct 12, 2021
1 parent f1b6616 commit c88521f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function numberToWords(num: string): string {
let output = EMPTY;
const length = num.length;

Array.from(num).forEach((d, idx) => {
for (let idx = 0; idx < length; idx++) {
const d = num[idx];
const digitIdx = (length - idx - 1) % 6;
const isMillion = length - 1 !== idx && digitIdx === 0;

Expand All @@ -25,7 +26,7 @@ function numberToWords(num: string): string {
output += LAN;
}

return;
continue;
}

const isSib = digitIdx === 1;
Expand All @@ -43,7 +44,7 @@ function numberToWords(num: string): string {
if (isMillion) {
output += LAN;
}
});
}

return output;
}
Expand Down

0 comments on commit c88521f

Please sign in to comment.