const str = '123456' const arr = str.split('') let sum = 0 arr.map((item) => { sum += parseInt(item) }) console.log('sum is:', sum)