Created
September 18, 2020 19:11
-
-
Save hassan-maavan/c69ed63796b37aad65f9bfcdcc35a847 to your computer and use it in GitHub Desktop.
16+18=214 For this Kata you will have to forget how to add two numbers together. In simple terms, our method does not like the principle of carrying over numbers and just writes down every number it calculates :-) You may assume both integers are positive integers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num1 = ('' + num1).split('').reverse() | |
num2 = ('' + num2).split('').reverse() | |
let max = Math.max(num1.length, num2.length) | |
let str = []; | |
for(let i = 0; i < max; i++) | |
str.push((parseInt(num1[i]) || 0) + (parseInt(num2[i]) || 0)) | |
num1 = str.reverse().join(''); | |
return parseInt(num1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment