JS中输入一个整数,判断大于0小于0还是等于0

<script type="text/javascript">
	var num=(parseInt(prompt("请输入数字")));//请输入数字
	if(num>0){//判定条件当输入数字大于0时
		document.write(alert("大于0"));
	}else if(num<0){//判定条件当输入数字小于0时
		document.write(alert("小于0"));
	}else{//判定条件当输入数字等于于0时
		document.write(alert("等于0"));
	}
</script>

猜你喜欢

转载自blog.csdn.net/weixin_44963099/article/details/89485546