Answers for "Write Number in Expanded Form"

0

Write Number in Expanded Form

const expandedForm = num => {
    let pow = []
    let decimal = []
    num = num.toString().split('')
    let len = num.length
    for(let i = 0; i <= len - 1; i++){
        pow.unshift(i)
    }
    num.forEach((x,index) => {
        x = parseInt(x)
        decimal.push(x*10**pow[index])
    })
    let toDecimal = decimal.filter(a => a !== 0)
    return toDecimal.toString().split(',').join(' + ')
};
console.log(expandedForm(70304))
Posted by: Guest on June-16-2020

Code answers related to "Write Number in Expanded Form"

Code answers related to "Javascript"

Browse Popular Code Answers by Language