02_ if_else if 練習

  • <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8" />
            <title>小花的相親</title>
        </head>
        <body>
            <script type="text/javascript">
                var manHeight = +prompt("請輸入男方身高(xxcm):");
                var manMoney = +prompt("請輸入男方財產(xx萬):");
                var manFace = +prompt("請輸入男方顏值(0-1000):");
                var girlWords;
                
                if (manHeight > 180 && manMoney > 1000 && manFace > 500 )
                {
                    girlWords = "我必定要嫁給他!";
                }
                else if (manHeight > 180 || manMoney > 1000 || manFace > 500 )
                {
                    girlWords = "嫁吧,比上不足,比下有餘。";
                }
                else
                {
                    girlWords = "不嫁!";
                }
                
                alert(girlWords);
                document.write(girlWords);
            </script>
        </body>
    </html>
相關文章
相關標籤/搜索