• + 0 comments

    I convert them to string and calculate the multiply with this function:

    function strMultiply(a,b){
        const strA = String(a).split("").reverse().join(''); //i
        const strB = String(b).split("").reverse().join(''); // j
        const result = new Array(strA.length + strB.length).fill(0);
        
        
        for(let i=0 ;i<strA.length;i++){
            for(let j=0;j<strB.length;j++){
                const mult = +strA[i] * +strB[j];
                const sum = result[i+j] + mult
                result[i+j] = sum % 10;
                result[i+j + 1] += Math.floor(sum/10) 
           }
            
        }
        
        while(result[result.length -1]===0){
            result.pop()
        }
        
        return result.reverse().join("")
    }