Then check if it's zero (because if it is, we can just return "zero").
Next, let's make sure we've defined the building blocks that will make up the final string. They include:
units
likeone
,thirteen
, etc.tens
values liketwenty
,thirty
, etc.scales
likethousand
, andmillion
Now we account for the various scales. Most of the scaling levels come up every 3 digits. Using this code block, we can get every 3 digits as chunks.

xxxxxxxxxx
start = string.length;
chunks = [];
while (start > 0) {
end = start;
chunks.push(string.slice((start = Math.max(0, start - 3)), end));
}
OUTPUT
Results will appear here.