js中输入一个数判断是奇数还是偶数,并输出结果

<script type="text/javascript">
	var num=(parseInt(prompt("请输入数字")));//输入数字
	if(num%2==0){//判定条件余数为0时为偶数
		document.write(alert("偶数"));
	}else{
		document.write(alert("奇数"));
	}
</script>

猜你喜欢

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