当前位置:网站首页>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
边栏推荐
- 2. Create your own NFT collections and publish a Web3 application to show them start and run your local environment
- Sum of three numbers
- Leetcode-160相交链表
- 540. Single element in ordered array / 1684 Count the number of consistent strings
- 2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境
- LeetCode-21合并两个有序链表
- NSI packaging script add file details
- Leetcode-128 最长连续序列
- R language ggplot2 visualization: gganimate creates a dynamic histogram animation (GIF), and displays the histogram and enter step by step along a given dimension in the animation_ Growth function and
- Static timing analysis (STA) in ic/fpga design
猜你喜欢
Salesmartly has some tricks for Facebook chat!
Calculation of intersection of two line segments
信度系数低怎么办?信度系数具体怎么算?
用WPF写一款开源方便、快捷的数据库文档查询、生成工具
Static timing analysis (STA) in ic/fpga design
LiveData postValue会“丢”数据
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
Write an open source, convenient and fast database document query and generation tool with WPF
6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷
C# SelfHost WebAPI (2)
随机推荐
Force buckle day33
Static timing analysis (STA) in ic/fpga design
Lumiprobe lumizol RNA extraction reagent solution
Basic concepts of binary tree
Depth first search - DFS (burst search)
Unity learning fourth week
斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
12种数据量纲化处理方式
Implementation of converting PCM file to WAV
How does factor analysis calculate weights?
PriorityQueue的用法和底层实现原理
Reading notes series "modern methods of C language programming" -- Chapter 2
用WPF写一款开源方便、快捷的数据库文档查询、生成工具
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
如何运营好技术相关的自媒体?
C operator overloads the query table
R language uses the aggregate function of epidisplay package to divide numerical variables into different subsets based on factor variables, and calculate the summary statistics of each subset
华为云专家详解GaussDB(for MySQL)新特性
Principal component calculation weight
Using OpenSSL encryption to rebound shell traffic