Expand a Number II

Published by Deep Xavier in

Create a function that expands a decimal number into a string as shown below:

25.24 ➞ "20 + 5 + 2/10 + 4/100"
70701.05 ➞ "70000 + 700 + 1 + 5/100"
685.27 ➞ "600 + 80 + 5 + 2/10 + 7/100"

Examples

expandedForm(5.44) ➞ "5 + 4/10 + 4/100"

expandedForm(46.66) ➞ "40 + 6 + 6/10 + 6/100"

expandedForm(87.04) ➞ "80 + 7 + 4/100"

expandedForm(123.025) ➞ "100 + 20 + 3 + 2/100 + 5/1000"

expandedForm(50.270) ➞ "50 + 2/10 + 7/100"

Notes

N/A

Watch a quick demo on how Edabit works.