without using any inbuilt method,pure logic
Code\njavascript []\n/**\n * @param {string} s\n * @param {number} k\n * @return {string}\n */\nvar digitSum = function (s, k) {\n\n    function rec(s) {\n     
# Code\n```javascript []\n/**\n * @param {string} s\n * @param {number} k\n * @return {string}\n */\nvar digitSum = function (s, k) {\n\n    function rec(s) {\n        if (s.length <= k) return s\n\n        let str = \'\';\n\n\n        for (let i = 0; i < s.length; i += k) {\n            let str2 = 0\n            for (let j = i; j < i + k && j < s.length; j++) {\n                str2 += Number(s[j]);\n            }\n            str += str2.toString()\n        }\n        console.log(str.length !== k)\n\n        if(str.length !== k){\n            return rec(str)\n        }else{\n            return str\n        }\n\n\n    }\n\n    return rec(s)\n};\n```
['JavaScript']