// chestnuts : Extract the fraction in the string , Calculate the average score after summarizing , And compare with each score , Output
var s=" Zhang San 56 branch , Li Si 74 branch , Wang Wu 92 branch , Zhao Liu 84 branch ";
var a=s.match(/\d+/g),sum=0;// Extract numbers
for (var i = 0; i < a.length; i++) {
sum+=parseFloat(a[i]);
}
var avg=sum/a.length;
function f() {
var n=parseFloat(arguments[1]);
return n+" branch "+"("+((n>avg)?(" Above average "+(n-avg)):(" Below average "+(avg-n)))+" branch )";
}
var s1=s.replace(/(\d+) branch /g,f);
console.log(s1);
当前位置:网站首页>[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
[JS] extract the scores in the string, calculate the average score after summarizing, compare with each score, and output
2022-07-05 10:53:00 【Muzi huaner】
边栏推荐
- 四部门:从即日起至10月底开展燃气安全“百日行动”
- Data types ntext and varchar are incompatible in the not equal to operator - 95 small pang
- Go-2-Vim IDE常用功能
- 华为设备配置信道切换业务不中断
- 小程序框架Taro
- DOM//
- 流程控制、
- Do you really understand the things about "prototype"? [part I]
- BOM//
- Blockbuster: the domestic IDE is released, developed by Alibaba, and is completely open source!
猜你喜欢
双向RNN与堆叠的双向RNN
Go-3-the first go program
关于 “原型” 的那些事你真的理解了吗?【上篇】
Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)
32:第三章:开发通行证服务:15:浏览器存储介质,简介;(cookie,Session Storage,Local Storage)
一次edu证书站的挖掘
【广告系统】Parameter Server分布式训练
[dark horse morning post] Luo Yonghao responded to ridicule Oriental selection; Dong Qing's husband Mi Chunlei was executed for more than 700million; Geely officially acquired Meizu; Huawei releases M
随机推荐
磨礪·聚變|知道創宇移動端官網煥新上線,開啟數字安全之旅!
BOM//
dsPIC33EP 时钟初始化程序
上拉加载原理
Web3基金会「Grant计划」赋能开发者,盘点四大成功项目
Go language-1-development environment configuration
Nine degrees 1480: maximum ascending subsequence sum (dynamic programming idea for the maximum value)
Honing · fusion | know that the official website of Chuangyu mobile terminal is newly launched, and start the journey of digital security!
关于vray 5.2的使用(自研笔记)(二)
Data type
Ad20 make logo
2022 t elevator repair operation certificate examination questions and answers
App各大应用商店/应用市场网址汇总
【广告系统】Parameter Server分布式训练
Data types ntext and varchar are incompatible in the not equal to operator - 95 small pang
风控模型启用前的最后一道工序,80%的童鞋在这都踩坑
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
DGL中异构图的一些理解以及异构图卷积HeteroGraphConv的用法
Share Net lightweight ORM
Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022