← Back to challenges

Sum of Round Numbers

JavaScriptHardalgorithmsmath

Instructions

Given a number, find the "round" of each digit of the number. An integer is called "round" if all its digits except the leftmost (most significant) are equal to zero.

  • Round numbers: 4000, 1, 9, 800, 90
  • Not round numbers: 110, 707, 222, 1001

Create a function that takes a number and returns the "round" of each digit (except if the digit is zero) as a string. Check out the following examples for more clarification.

Examples

sumRound(101) ➞ "1 100"

sumRound(1234) ➞ "4 30 200 1000"

sumRound(54210) ➞ "10 200 4000 50000"

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.