javascript direct way 84ms
\nconst digitSum = (s, k) => {\n    while (s.length > k) {\n        let t = \'\'; // each round accumalate new string t\n        for (let i = 0; i < s.length; i
```\nconst digitSum = (s, k) => {\n    while (s.length > k) {\n        let t = \'\'; // each round accumalate new string t\n        for (let i = 0; i < s.length; i += k) {\n            let sub = s.slice(i, i + k), sum = 0;\n            for (const c of sub) sum += c - \'0\'; // sum of each digits\n            t += sum; // rebuild new string with sum\n        }\n        s = t; // update new string to s\n    }\n    return s;\n};\n```
['String', 'JavaScript']