let a = prompt('请输入想要转换的数字'); let b = prompt('请输入想转换的类型(1:取整 2:向下取整 3: 归零)'); function c (a,b){ if( b == 1 ){ let x = parseFloat(a); let g = parseInt(a); if( x - g >= 0.5){ g++; console.log(g); }else{ console.log(g); } } else if( b == 2 ){ let g = parseInt(a); console.log(g); }else if( b == 3 ){ let g = 0 ; console.log(g); } } c(a,b); // 绝对值 let a = prompt('请输入'); if( a >= 0){ console.log(a); }else{ a = a * -1; console.log(a); }