Created
December 31, 2021 10:06
-
-
Save smitroshin/048b8a681a0b9a868be3342c607c9f4d to your computer and use it in GitHub Desktop.
Decompose integer number by grade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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