1

I was trying to convert those strings to integer, but when I did it this way, it would add +1 on the num1I value, and after i try to get num3 the value would get +1 once again. Am I missing something?

/**
 * @param {string} num1
 * @param {string} num2
 * @return {string}
 */
var addStrings = function(num1, num2) {
    num1I = num1
    num2I = num2
    console.log(num1I)
    console.log(num2I)
    //9333852702227987
    //85731737104263
    num1I = num1I*1
    num2I = num2I*1
    console.log(num1I)
    console.log(num2I)
    //9333852702227988
    //85731737104263
    num3 = num1I + num2I
    num3 = num3 + ""
    return num3
};
console.log(addStrings("9333852702227987","85731737104263"))
//9419584439332252

It was the same when I tried just adding + in front of the string. The result should be 9419584439332250, and it's not it's 9419584439332252.

derpirscher
  • 14,418
  • 3
  • 18
  • 35

0 Answers0