Skip to content

Instantly share code, notes, and snippets.

@asm-jaime
Created October 2, 2016 14:13
Show Gist options
  • Save asm-jaime/78659d435bb2c4c6ed94e0e611cec130 to your computer and use it in GitHub Desktop.
Save asm-jaime/78659d435bb2c4c6ed94e0e611cec130 to your computer and use it in GitHub Desktop.
resolve summ without cast (]:_>)
'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