let x = prompt('请输入一个数字'); function a ( t ){ let q = Number(x); let b = parseInt(x); let c = 0; if( b > 0 ){ if( q - b > 0.5){ b = parseInt(b); b++; console.log(b); } else{ b = parseInt(b); console.log(b); } } else if( b < 0 ) { if(q - b < -0.6){ b = parseInt(b); b--; console.log(b); }else{ b = parseInt(b); console.log(b); } }else{ console.log(c); } } a( x );