Web自学之JS循环小练习

Web自学之JS循环小练习

 

前言

JS循环语句的两个小测试流氓表白法和流氓道歉法,代码编写纯属无聊哈!

如果有兴趣的朋友可以看看!😂😂😂

 


 

一、流氓表白法

代码如下:

 

​<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    var num = 0;
    do {

        var input = prompt('你是不是喜欢我? 回答 是或不是');
        if (input == '是') {
            break;
        }
        else {
            alert('回答错误! 请你认真回答这个问题!')
            if ((num + 1) % 4 == 0) {
                alert('不要欺骗自己!我想听听你内心的声音');
            }
        }
        num++;
    } while (input != '是')
    alert('我就知道你会喜欢我的!');
    alert('爱你,么么哒!');

</script>

<body>

</body>

</html>

二、流氓道歉法

代码如下

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>求求你原谅我吧</title>
</head>
<script>
    var num = 0;
    do {

        var input = prompt('你是不是还在生我的气? \n回答:是或不是');
        if (input == '不是') {
            alert('真的吗?');
            do {
                var input2 = prompt('你是真的不生我气了吗? \n回答:真的或假的');
                if (input2 != '真的') {
                    alert('你好坏呀!我就知道你会这么说的,我再给你一次机会!\n请你认真回答!');
                }
                else {
                    break;
                }
            } while (input2 != '真的')
            // break;
        }
        else {
            alert('回答错误! 请你认真回答这个问题!')
            if ((num + 1) % 4 == 0) {
                alert('不要欺骗自己!我想听听你内心的声音');
            }
        }
        num++;
    } while (input != '不是')
    alert('我就知道你不会生我气的!');
    alert('爱你,么么哒!');

</script>

<style>
    body {
        width: auto;
        height: auto;
        background-image: url('https://gss0.baidu.com/9vo3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/728da9773912b31b717fbf4f8718367adab4e141.jpg');
        background-repeat: no-repeat;
        background-position: center top;
    }
</style>

<body>
</body>

</html>

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xiaozhangtxue

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值