Created
October 2, 2016 14:13
-
-
Save asm-jaime/78659d435bb2c4c6ed94e0e611cec130 to your computer and use it in GitHub Desktop.
resolve summ without cast (]:_>)
This file contains hidden or 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
'use strict' | |
const super_cast = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; | |
const convert = (arr_char) => { | |
let real_num = 0; | |
for (let i = 0; i < arr_char.length; ++i) { | |
real_num = real_num + Math.pow(10, i) * super_cast.indexOf(arr_char[i]); | |
}; | |
return real_num; | |
} | |
const sum_str = (a, b) => { | |
return (convert(a.split('')) + convert(b.split(''))).toString(); | |
} | |
console.log(convert(['1', '1'])); | |
console.log(sum_str('232','23')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment