题解 | #乘法#
乘法
http://www.nowcoder.com/practice/6429776e4630435cbc3eeb36bdf41f83
function multiply(a, b) {
if(a > 1&& b < 1){
b_dottod_length = (''+b).slice((''+b).indexOf('.')+1);
dottod = -(a.toString.length)+1+b_dottod_length.length
}else if(b > 1&&a < 1){
a_dottod_length = (''+a).slice((''+a).indexOf('.')+1);
dottod = -(b.toString.length)+1+a_dottod_length.length;
}else if(b < 1&& a < 1){
a_dottod_length = (''+a).slice((''+a).indexOf('.')+1);
b_dottod_length = (''+b).slice((''+b).indexOf('.')+1);
dottod = a_dottod_length.length + b_dottod_length.length
console.log(dottod)
}else{
return a*b;
}
return (a*b)>=1?(a*b):(a*b).toFixed(dottod)}
