Skip to content

Instantly share code, notes, and snippets.

@OlegLustenko
Created March 14, 2016 09:13
Show Gist options
  • Save OlegLustenko/141f5ec267b16b8c2a89 to your computer and use it in GitHub Desktop.
Save OlegLustenko/141f5ec267b16b8c2a89 to your computer and use it in GitHub Desktop.

Revisions

  1. OlegLustenko created this gist Mar 14, 2016.
    11 changes: 11 additions & 0 deletions add.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    function add (a, b) {
    let res = '', c = 0
    a = a.split('')
    b = b.split('')
    while (a.length || b.length || c) {
    c += ~~a.pop() + ~~b.pop()
    res = c % 10 + res
    c = c > 9
    }
    return res
    }