0

I am try to solve a problem of LEETCODE using JavaScript, the problem is Multiply Strings and the solution is:

const string = (num) => {
     return '' + num
 }
 
var multiply = function(num1, num2) {
    let result =  string(num1*num2)
    return result
    
};

console.log(multiply("123456789",
"987654321"))

it should return "121932631112635269"

but it returns 121932631112635260

Any Solution?

"123456789" * "987654321" should return "121932631112635269"

but it returns 121932631112635260

Pointy
  • 405,095
  • 59
  • 585
  • 614
  • That number is [two orders of magnitude larger than `Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) – Jared Smith Dec 05 '22 at 16:25
  • Also related: [Multiply strings](https://stackoverflow.com/q/51424468) – VLAZ Dec 05 '22 at 16:26
  • Check https://leetcode.com/problems/multiply-strings/solution/ – James Dec 05 '22 at 16:47

0 Answers0