当前位置:网站首页>[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 :

边栏推荐
- IDL调用6S大气校正
- Pygame:外星人入侵
- Interface parameters return encapsulated class result
- Use (offset, page) in JS to achieve login effect
- mysql数据库实验实训6,数据视图(详细)
- Use of flask
- 数据分析与数据挖掘实战案例本地房价预测(716):
- 硬核结构体,暴力解读
- ThreadLocal thread safety example and its principle
- Use echars to realize water drop, ring, segmentation, stacking, organization chart, map outline and other charts
猜你喜欢

Installation and fast use of Mongo DB stand-alone version

645. 错误的集合

ThreadLocal thread safety example and its principle

Uniapp uses uview to realize folding panel

Internship project 3- change owner

小程序云开发表单提交并在页面中获取数据

Convolutional neural network

The code of yolov5 model for pest identification in Title A of the 10th Teddy cup data mining challenge (has been run through, original works, continuously updated)
![[2022 10th Teddy Cup Challenge] Title A: complete version of pest identification (general idea. Detailed process and code and results CSV in compressed package)](/img/e6/beea0bb0a9f4b41206c6fcb130fdfd.png)
[2022 10th Teddy Cup Challenge] Title A: complete version of pest identification (general idea. Detailed process and code and results CSV in compressed package)

IDL 6S查找表
随机推荐
computed和watch的区别
C语言练习2
Infinite classification
【Es6】forEach,for... in ,for... Of column, which allows you to quickly distinguish the usage and differences of various for statements through project cases (full version). There are detailed notes ins
es6新增-数组部分
决策树原理和案例应用-泰坦尼克号生存预测
es6新增-运算符的扩展
【Es6】利用添加数据,筛选并传输至页面等多项功能实现案例
STL容器——set集合的应用
【Es6】详细解说Set ,Array的常用对象及其他方法(完整版)
【Es6】快速实现用户信息打印至页面中
【C语言—零基础第十四课】变量的作用域与存储类
Use of flask
PAT乙级1017: A除以B
父组件加scoped有时也会影响子组件
【C语言_复习_学习第二课】什么是进制?进制之间应该如何转换
简单快速建立pytorch环境YOLOv5目标检测 模型跑起来(超简单)
滚动轮加载的两种js方法及模态框拖拽归总
C语言 带你 手撕 通讯录
Word2Vec原理及应用与文章相似度(推荐系统方法)