1 line in JavaScript


  • 0
    var complexNumberMultiply = function(a, b) {
        return [`${a}+${b}`.replace(/i/g, '').split('+')].reduce((d, v) => `${v[0] * v[2] - v[1] * v[3]}+${v[0] * v[3] + v[1] * v[2]}i`, 0);
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.