20/08/01 21:52:47.76 xRTQ61eG.net
>>165
function mul(a, b) {
let prod = 0;
const unit = Math.sign(a) + Math.sign(b) ? 1 : -1;
for (let i = 0; i < Math.abs(a); i++)
for (let j = 0; j < Math.abs(b); j++)
prod += unit;
return prod;
}
console.log(mul(-6, -7)); //=> 42
console.log(mul(-6, 7)); //=> -42
低得点ww