Ad
Code
Diff
  • function digitizeNumber(number) {
        let digits = [];
        let n = +number || 0;
        
        while (n != 0) {
            digits.push(Math.round(n % 10));
            n = Math.round(n / 10);
        }
        
        digits.reverse();
        return digits
    }
    • function digitizeNumber(number) {
    • let digits = [];
    • let stringNumber = number && number.toString() || "";
    • for (let i = 0; i < stringNumber.length; i += 1) {
    • digits.push(+stringNumber.charAt(i));
    • }
    • return digits;
    • let digits = [];
    • let n = +number || 0;
    • while (n != 0) {
    • digits.push(Math.round(n % 10));
    • n = Math.round(n / 10);
    • }
    • digits.reverse();
    • return digits
    • }