zoukankan      html  css  js  c++  java
  • js 学习之路6: if...else...条件语句的使用

    1.1

    if (...)

    {

    ...

    }

    else

    {

    ...

    }

    <!DOCTYPE html>
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <body>
    
    <script charset = "utf-8">
    
    function myfunction(){
        var x = 11;
        var y = x % 2;
        document.write(y + "<br>");
        if (x % 2 == 1){
            document.write("单数");
        }
        else
        {
            document.write("双数");
        }
    }
    
    myfunction();
    
    </script>
    
    </body>
    </html>

    1.2

    if (条件1)

    {

    ...

    }

    else if (条件2)

    {

    ...

    }

    else

    {

    ...

    }

    <!DOCTYPE html>
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <body>
    
    <script charset = "utf-8">
    
    function myfunction(x){
        var y = x % 2;
        if (x % 2 == 0){
            document.write("双数");
        }
        else if (x > 10)
        {
            document.write("大于10的单数");
        }
        else
        {
            document.write("普通单数");
        }
        
        document.write("<br>");
        document.write(x);
    }
    
    myfunction(15);
    
    </script>
    
    </body>
    </html>
  • 相关阅读:
    模型评估方法
    欠拟合、过拟合、偏差、方差
    机器学习基本概念
    Hive 的基本概念
    Flume的Channel
    Flume的Sink
    Flume的Source
    Flume 安装和配置
    Flume的基本概念
    BIO & NIO & NIO常见框架
  • 原文地址:https://www.cnblogs.com/zrmw/p/10329903.html
Copyright © 2011-2022 走看看