js的数学对象

 

	console.log(Math.ceil(12.3))//13//返回的是大于该数字的最小整数
			console.log(Math.floor(12.7))//12//返回的是小于该数字的最大整数
			console.log(Math.round(12.6))//13//将数进行四舍五入
			console.log(Math.max(12,30,15,100))//求最大值 两个及多个数中的最大值
			console.log(Math.pow(2.3))//2的三次方
<input type="text" name="result" id="result" value=""/>
		<input type="button" id="csz" value="猜数字"/>
		<script type="text/javascript">
			//随机产生数字
			console.log(Math.floor(Math.random()*max))
			//猜数字
			var num=Math.floor(Math.random()*max)
			console.log(num)
			document.getElementById("csz").onclick=function(){
				//获取文本框中输入的数字
				var result=Number(document.getElementById("result").value)
				if(result>num){
					alert("你猜的数字太大了,请重新输入")
				}else if(result<num){
					alert("你猜的数字太小了")
				}else if(result=num){
					alert("你猜对了")
				}else(num=5){
					alert("你输了")
				}
			}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值