I'm trying to create this simple logic whereas I want the array value to add to the previous value. For example the code below, the 18 should carry the 1 and add to the the 9 and the 9 will be 10 then carry the one and add to the 7 and will be 8 and so on. I think I'm on the right track but I can't figure out the rest.
This is for addition math generator I'm working on.
var foo = [7, 9, 18];
var bar = foo.map(i=>{
return i % 10
})
console.log(bar) // [7,9,8] I want it to be [8,0,8]