Skip to content

Instantly share code, notes, and snippets.

@samuelastech
Created April 26, 2022 10:32
Show Gist options
  • Save samuelastech/eef57e8b72ad98c2f0cabf0e971f6856 to your computer and use it in GitHub Desktop.
Save samuelastech/eef57e8b72ad98c2f0cabf0e971f6856 to your computer and use it in GitHub Desktop.
Converting a number into array
/**
* Takes a number and create an array from it
* @param {Number} number
* @returns {Object}
*/
function numberToArray(number){
return Array.from(String(number), digit => {
return Number(digit)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment