title: Javascript loop to add to the previous value if the current value is greater than 10
body: <p>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.</p>
  
  <p>This is for addition math generator I'm working on.</p>
  
  <pre><code>var foo = [7, 9, 18];
  var bar =  foo.map(i=&gt;{
    return i % 10
  })
  
  console.log(bar) // [7,9,8]  I want it to be [8,0,8]
  </code></pre>