Skip to content

Instantly share code, notes, and snippets.

@toreylittlefield
Last active July 4, 2022 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toreylittlefield/4571abef355a15b7f40c2702ef1c0a8a to your computer and use it in GitHub Desktop.
Save toreylittlefield/4571abef355a15b7f40c2702ef1c0a8a to your computer and use it in GitHub Desktop.
Incrementing Strings - Torey
(function (n) {
for (let i = 0; i < n + 1; i++) {
const remainder = n - i;
const string = Array.from({ length: n }, (_, index) => {
return remainder <= index ? i : ' ';
}).join('');
console.log(string);
}
/* console.log(" 1")
console.log(" 22")
console.log(" 333")
console.log(" 4444")
console.log("55555") */
})(5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment