当前位置:网站首页>JS find the next adjacent element of the number in the array
JS find the next adjacent element of the number in the array
2022-07-01 18:48:00 【Mark community】
let arr = [“2”, “4”, “6”, “8”, “10”, “12”, “14”, “16”, “18”, “20”, “22”, “24”, “27”, “30”, “33”, “36”, “42”, “48”, “54”, “60”] var rr = []; function name(n) { let num = Number(n); for (let i = 0; i < arr.length; i++) { const element = arr[i]; if(element!=num){ rr.push(num–); } } return rr.find((el)=>{ let newel = String(el); return arr.includes(newel); }) } let newn = String(name(“56”));
console.log(newn);
For more information, please refer to the original , Reproduced from :http://www.mark-to-win.com/tutorial/50905.html
边栏推荐
- The R language cartools package divides the data, the scale function scales the data, the KNN function of the class package constructs the k-nearest neighbor classifier, and the table function calcula
- LeetCode-21合并两个有序链表
- Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)
- R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
- 力扣每日一题-第32天-589.N×树的前序遍历
- GAMES202作业0-环境搭建过程&解决遇到的问题
- Introduction to easyclick database
- 数据库基础:select基本查询语句
- R语言使用epiDisplay包的dotplot函数通过点图的形式可视化不同区间数据点的频率、使用pch参数自定义指定点图数据点的形状
- 因子分析怎么计算权重?
猜你喜欢

12. Design of power divider for ads usage record

docker 部署mysql8.0

Leetcode-128 longest continuous sequence

解决方案:可以ping别人,但是别人不能ping我

Li Kou daily question - Day 32 -589 N × Preorder traversal of tree

实例讲解将Graph Explorer搬上JupyterLab

1、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》什么是NFT

创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)

关于企业中台规划和 IT 架构微服务转型

Leetcode-160 intersecting linked list
随机推荐
About enterprise middle office planning and it architecture microservice transformation
Financial judgment questions
Lumiprobe non fluorescent alkyne EU (5-ethynyluridine)
LeetCode-21合并两个有序链表
研究了11种实时聊天软件,我发现都具备这些功能…
540. Single element in ordered array / 1684 Count the number of consistent strings
Livedata postvalue will "lose" data
6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
磁盘的基本知识和基本命令
Relational database management system of easyclick
每周推荐短视频:警惕“现象”与“问题”相互混淆
Lumiprobe lumizol RNA extraction reagent solution
力扣每日一题-第32天-1232. 缀点成线
R语言使用epiDisplay包的followup.plot函数可视化多个ID(病例)监测指标的纵向随访图、使用n.of.lines参数指定显示的病例数
Sum of three numbers
Case study on comprehensive competitiveness of principal components
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
用WPF写一款开源方便、快捷的数据库文档查询、生成工具
搭建一个通用监控告警平台,架构上需要有哪些设计
Implementation of converting PCM file to WAV