September 13th, 2024
What's missing in this code?
function func(num) {
let count = 0;
let shapeStages = [];
while (num >= 10) {
let digits = num.toString().match(
).map(Number);
shapeStages.
("#".
(digits.length));
num = digits.reduce((a, b) => a + b);
;
}
shapeStages.push("#".repeat(num.toString().length));
return shapeStages.join('\n');
}
func(1679583);
// #######
// ##
// ##
// #
func(12345);
// ######
// ##
// #
func(10);
// ##
// #
Type or select from these options