用函数调用循环语句if...else与多重if语句的用法

<script>

//..............................判断用户输入的年份是否是闰年.....................................

  function getYear(){

    var year=prompt("请输入年份");

    if((year%4==0&&yeat%100!=0)||year%400==0){

      alert("今年是闰年");

    }else{  

      alert("今年不是闰年");  

    }

  }

扫描二维码关注公众号,回复: 4826509 查看本文章

//.........................................米莱托指数.................................................................

  function getWeight(){

    var height=prompt("请您输入您的身高");

    var weight=prompt("请您输入您的身高"); 

    var calc=weight/(height*height);

    if(calc>25){

      alert("偏胖");

    }else if(calc<20){

      alert("偏瘦");

    }else{

      alert("标准体重");

    }

  }

</script>

<button onclick="getYear()"></button>

猜你喜欢

转载自www.cnblogs.com/luYing666/p/10237518.html