前端初级学者

### if条件判断

 小明考试成绩下来了,拿着试卷回了家

妈妈对小明说:

超过90分的话就去动物园玩;

超过80分的话可以看两个小时电视;

及格的话就奖励一个鸡腿;

否则就等着挨打吧

    var scope = 110;

    if (scope > 90) {

     alert("去动物园")

    } else if (scope > 80) {

        alert("看电视")

    } else if (scope >= 60) {

       alert("吃鸡腿")

    } else {

       alert("挨揍")

    }

 

 

       

 ### for循环99乘法表

 for(i=0;i<=9;i++){

      for (j=1;j<=i;j++) {

         ###(第一种方法) document.write(i+"*"+j+"="+i*j+"&nbsp; &nbsp; &nbsp;")

          ####(第二种)document.write(`${i}*${j}=${i*j}&nbsp;&nbsp;&nbsp`)

      }

       document.write("<br/>")

    }

 

### 遍历数组

let Array=[5,8,9,10,45]

for (let index = 0; index < Array.length; index++) {

   document.write(`${Array[index]}</br>`)

    }


 

 

### 遍历下列性别为男的去打篮球性别为女的回家

 let studentArray=[

  {"name":"张三","sex":"男","age":"18","height":"178","weight":"145","like":["唱歌","跳舞","追剧"]},

   {"name":"李四","sex":"男","age":"18","height":"188","weight":"135","like":["rap","追剧","打篮球"]},

     {"name":"小莉","sex":"女","age":"18","height":"168","weight":"105","like":["唱歌","打篮球","追剧"]}

     ]

    for (let i = 0; i < studentArray.length; i++) {

        if(studentArray[i]["sex"]=="男"){

         document.write(`${studentArray[i]["name"]}去打篮球</br>`)

       }else if(studentArray[i]["sex"]="女"){

           document.write(`${studentArray[i]["name"]}放学后回家 </br>`)  

       }

       else{

           console.log(studentArray[i])

       }

     }

 

###  遍历爱好

     for (let i = 0; i < studentArray.length; i++) {

      for(let j = 0;j<studentArray.length;j++){

           if(studentArray[i]["like"][j]=="rap")

              document.write(`${studentArray[i]["name"]}爱rap </br>`)

       }

   

 

### 3 写出下面程序输出结果(字面量)

```javascript

var arr1 =[1, 2, 3];

var arr2 = arr1;

var arr3 =[...arr1];

arr2[0]= 5;

console.log(arr1); // [5,2,3]

console.log(arr2);// [5,2,3]

console.log(arr3);// [1,2,3]

 #### flex布局

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <div style="width: 100%;">

        <!-- 头部 -->

        <div style="width: 100%;height: 100px;background-color: aquamarine;"></div>

        <!-- 中间 -->

        <div style="width: 100%;height: 500px;display: flex;">

            <!-- 左边 -->

            <div style="flex:1;background-color:beige"></div>

            <!-- 中间 -->

            <div style="flex:6;background-color: bisque;">

                <!-- 上 -->

                <div style="width: 100%;height: 100px;display: flex;">

                    <div style="flex: 1;background-color: rgb(24, 134, 230);"></div>

                    <div style="flex: 1;background-color: rgb(172, 214, 57);"></div>

                </div>

                <!-- 中 -->

                <div style="width: 100%;height: 200px;background-color: rgb(214, 59, 59);display: flex">

                    <div style="flex: 1;background-color: rgb(57, 71, 70);">

                        <div style="width: 100%;height: 50px;background-color: rgb(108, 111, 160);"></div>

                        <div style="width: 100%;height: 150px;background-color: rgb(92, 98, 226);"></div>

                    </div>

                    <div style="flex: 1;background-color: rgb(218, 198, 90);"></div>

                </div>

                <!-- 下 -->

                <div style="width: 100%;height: 200px;background-color: rgb(109, 105, 105);display: flex;">

                    <div style="flex: 3;background-color: rgb(146, 93, 189);">

                        <div style="width: 100%;height: 150px;background-color: rgb(108, 111, 160);"></div>

                        <div style="width: 100%;height: 50px;background-color: rgb(92, 98, 226);"></div>

                    </div>

                    <div style="flex: 1;background-color: rgb(119, 115, 122);"></div>

                </div>

            </div>

            <!-- 右边 -->

            <div style="flex:1;background-color: blue;"></div>

        </div>

        <!-- 底部 -->

        <div style="width: 100%;height: 100px;background-color: aquamarine;"></div>

    </div>

</body>

</html>

这个是flex布局的效果图。

z

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值