当前位置:网站首页>[ES6] quickly print user information to the page
[ES6] quickly print user information to the page
2022-07-19 05:12:00 【Create splendid -- hand in hand with you】
Case study : A set of personnel information , Output to the page to display .
HTML Framework content :
<table border="1">
</table>
js Implementation content :
let newarray = [
{realname:' Zhang San ',scroe:60},
{realname:' Li Si ',scroe:70},
{realname:' Wang Wu ',scroe:80},
{realname:' Zhao Liu ',scroe:98},
{realname:' Sun Qian ',scroe:57},
{realname:' Sun Lin ',scroe:30},
]
let str = '';
let jg;
let tbody = document.querySelector('table');
let tonewarray = newarray.map((item)=>{
if(item.scroe>=60){
jg=' pass ';
}else{
jg=' fail, ';
}
return {...item,jg};
})
tonewarray.forEach(item=>{
tbody.innerHTML =str +=`<tr><td> full name :${item.realname}</td><td> achievement :${item.scroe}</td><td>${item.jg}</td> </tr>` ;
})
case analysis :
// case analysis : First create an array object , Define a connection variable and store information about students' grades ( Pass and fail ) Content . Get the tag elements in the page ,
// By using machining array.map() Put the judged content inside and return its value ( Ternary operators can also be used here : Friends can try to write , If there are fans who don't understand, you can
// Private Blogger , Answer for you ).
// Through the above judgment, two values are returned , One is the object in the array , The other is the result given by judgment
// adopt forEach() loop Use the previously defined connection variable to insert the relevant attributes in the table
Show the effect :

边栏推荐
- cookie是否有效时间限定?如何设置cookie?手把手教你设置
- es6新增-字符串部分
- 轮播图移动速度(匀速,缓动)案例归总
- Submit the uniapp form (input, radio, picker) to get the parameter value
- 【LeetCode——编程能力入门第二天】运算符(位1的个数/整数的各位积和之差)
- (精讲)Es6 剩余参数,ES6内置对象,模板字符串内容(详例宝典)及灵活运用项目的实战案例
- Pat class B 1002: write this number
- Interface parameters return encapsulated class result
- 读论文《Learning to Measure Changes: Fully Convolutional Siamese Metric Networks for Scene Change Detec》
- es6新增-数组部分
猜你喜欢

Internship project 2 - Homepage configuration - my data module

Simply and quickly establish a pytorch environment yolov5 target detection model to run (super simple)

微信小程序获取年月日周及早上、中午、晚上

简单快速建立pytorch环境YOLOv5目标检测 模型跑起来(超简单)

645. 错误的集合

Asynchronous data SMS verification code

Applet cloud development upload pictures to cloud storage

【C语言_复习_学习第二课】什么是进制?进制之间应该如何转换

Internship project 1 - personalized homepage configuration

小程序editor富文本编辑使用及rich-text解析富文本
随机推荐
获取URL参数的两种方法及location对象的各项获取方式
获取数组中对象内部的数值最大与最小值多功能版及点名系统完整版并展示效果
Mysql database experiment training 6, data view (detailed)
学习C语言的第五天
uniapp 表单(input、radio、picker)提交获取参数值
IText modify PDF Text
About the current response, the method getoutputstream() has been called
【C语言—零基础_学习_复习_第五课】基本运算符的运算性质
【C语言—零基础第七课】顺序结构与选择结构
Actual cases of data analysis and data mining local house price prediction (716):
轮播图的两种方法及自动轮播
H5页面使用js生成二维码
热更新及其原理
Interface parameters return encapsulated class result
UML(用例图,类图,对象图,包图)
Es6 真实案例解构(多维数组对象)全新案例:
读论文《Learning to Measure Changes: Fully Convolutional Siamese Metric Networks for Scene Change Detec》
Baidu map realizes thermal map
es6新增-字符串部分
Es6最新常用知识宝典(能够帮助你解决面试题困惑,编写程序中出现的问题等)