Skip to content

Instantly share code, notes, and snippets.

@smitroshin
Created December 31, 2021 10:06
Show Gist options
  • Save smitroshin/048b8a681a0b9a868be3342c607c9f4d to your computer and use it in GitHub Desktop.
Save smitroshin/048b8a681a0b9a868be3342c607c9f4d to your computer and use it in GitHub Desktop.
Decompose integer number by grade
/**
* Decompose integer number by grade
*
* @param {number} num
* @returns {number[]}
*/
const decomposeIntNr = (num) =>
`${num}`.split('').map((itm, i, arr) => itm * 10 ** (arr.length - i - 1));
console.log(decomposeIntNr(346)); // Output: [300, 40, 6]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment