0

Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
You must solve the problem without using any built-in library for handling large integers (such as BigInteger). You must also not convert the inputs to integers directly.

Here is My code:

/**
 * @param {string} num1
 * @param {string} num2
 * @return {string}
 */
var addStrings = function(num1, num2) {
  var num1Int = parseInt(num1);
  var num2Int = parseInt(num2);
  var sum = num1Int + num2Int;
  var sumString = sum.toString();
  return sumString;

};
console.log(addStrings("11", "123"));
Micha Wiedenmann
  • 18,825
  • 20
  • 87
  • 132
  • Welcome to Stack Overflow! Visit the [help], take the [tour] to see what and [ask]. Please first ***>>>[Search for related topics on SO](https://www.google.com/search?q=javascript+add+large+integers+without+library+site%3Astackoverflow.com)<<]`](https://meta.stackoverflow.com/questions/358992/ive-been-told-to-create-a-runnable-example-with-stack-snippets-how-do-i-do) snippet editor. – mplungjan Oct 26 '21 at 08:11

0 Answers0