implement BigInt addition
2022年5月1日小于 1 分钟
implement BigInt addition
Question
Luckily we have BigInt in JavaScript so handle big numbers.
What if we need to do it by ourselves for older browsers?
You are asked to implement a string addition function, with all non-negative integers in string.
add('999999999999999999', '1')
// '1000000000000000000'
Don't use BigInt directly, it is not our goal here.
Code
/**
* @param {string} num1
* @param {string} num2
* @return {string}
*/
function add(num1, num2) {
// your code here
}
Related
- implement BigInt subtraction
- implement BigInt addition with sign
- implement BigInt subtraction with sign