Skip to content

Instantly share code, notes, and snippets.

@lovisgod
Forked from OlegLustenko/add.js
Created January 6, 2020 11:08
Show Gist options
  • Save lovisgod/9e5f805923f82d9a157fe86d2f54a662 to your computer and use it in GitHub Desktop.
Save lovisgod/9e5f805923f82d9a157fe86d2f54a662 to your computer and use it in GitHub Desktop.
Adding big numbers JavaScript (from codewars.com)
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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment