当前位置:网站首页>JS question brushing exercise - niuke.com
JS question brushing exercise - niuke.com
2022-07-19 14:26:00 【Front end Xiaobai is moving forward】
During this period of time, some friends are asking if there is any good question brushing website
Here I recommend a question brushing website Click to visit Niuke
Niuke supports the learning of multiple programming languages , Interview questions of major Internet companies , From foundation to elevation , Come and experience it !
introduction
Some time ago, I wanted to find some websites to improve js level , Inadvertently enter Niuke network , Niuke network has front-end html、css、js Exercises , Basic , Have high , Today I'm going to practice , I think Niuke has many advantages :
- The code is easy to debug , It is also very convenient to run
- The page is relatively simple , There's not so much fancy
- The overall quality of the exercise questions is good
Catalog
Front end interviewer tears questions
Event delegation
describe
Please complete it JavaScript Code , Requirements are as follows :
- to "ul" Add click event to tag
- When clicking on a "li" When labeling , The label content is spliced ".“ Symbol . Such as : some "li" When the tag is clicked , The label reads ”…"
Be careful : You have to use DOM0 Level standard event (onclick)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<ul>
<li>.</li>
<li>.</li>
<li>.</li>
</ul>
<script type="text/javascript"> // The completion code </script>
</body>
</html>
My answer :
document.querySelector('ul').onclick = function(event) {
event.target.innerText += '.'
}
analysis :
This question is about basic knowledge ,
target
ExpressCurrently triggered events
, By selecting the parent elementul
, Then the event agent , Then we get the answer
Array weight removal
describe
Please complete it JavaScript Code , It is required to remove the duplicate numeric items in the array parameters and return the array .
Be careful : Array elements contain only numbers
Example 1
Input :_deleteRepeat([-1,1,2,2])
Output :[-1,1,2]
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<script type="text/javascript"> const _deleteRepeat = array => {
// The completion code } </script>
</body>
</html>
My answer :
<script type="text/javascript">
const _deleteRepeat = array => {
// The completion code
return [...new Set(array)]
}
</script>
analysis :
This problem can be said to be completely for nothing ,es6 Medium
set
Collection can be easily solved ,set The collection has the function of automatic de duplication ,es6 Knowledge is detailed in es6 Knowledge summary
Quick sort
describe
Please complete it JavaScript Code , It is required to sort the numbers in the array parameters from small to large and return the array .
Be careful :1. Array elements contain only numbers
2. Please use the quick sort method first
Example :
Input : _quickSort([0,-1,1,-2,2])
Output :[-2,-1,0,1,2]
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<script type="text/javascript"> const _quickSort = array => {
// The completion code } </script>
</body>
</html>
My answer :
<script type="text/javascript">
const _quickSort = array => {
// The completion code
array.sort((a,b)=>{
return a-b
})
return array
}
</script>
analysis :
In fact, this problem is not difficult , Array
sort
Method to sort , however sort Method defaults tounicode code
Sequential arrangement , Here you pass in a function , Implement sorting from small to large ,sort See the article for details js in sort() Detailed explanation of the method
Summary
While learning knowledge , We must always come back and do some review , Only in this way can we make progress , Practicing exercises can help us consolidate our knowledge , Niuke is worth brushing questions to improve yourself !
边栏推荐
- Uniapp Gaode map positioning function
- Can ping command still play like this?
- 手册不全,如何手工刨出TongWeb的监控信息?
- Is it true that tongdaxin opens an account? Is it safe for tongdaxin to open an account?
- 05--- antireflective film
- TongWeb生产系统应急处理方案
- Configure spectrum navigation for Huawei wireless devices
- Pyside2嵌入Matplotlib的绘图
- 非凸優化問題經典必看綜述“從對稱性到幾何性”,羅切斯特大學等
- Redis source code and design analysis -- 2 Linked list
猜你喜欢
JVM performance optimization
Dr. Tao's lunar line reverses by 6.0
(with source code) a variety of machine learning models (knn\lr\rf\ada\xg\gbdt...) Model training in precipitation downscaling under
Redis source code and design analysis -- 3 Dictionaries
O'Neill's RPS curve compilation method (original by Dr. Tao)
智康护物业养老服务方案
Code Runner for VS Code,下载量突破 4000 万!支持超过50种语言
STM32 positioning hardfault location method and encountered situation in keil environment
Matplotlib draw multi line graph (solve the problem that Matplotlib Chinese cannot be displayed)
Several small open source projects of mine over the years
随机推荐
手册不全,如何手工刨出TongWeb的監控信息?
TongWeb生产系统应急处理方案
【ACWing】2492. HH Necklace
00 后博士获聘南大特任副研究员,曾 4 岁上小学,14 岁考入南大!
Luo Gu: p3092 [usaco13nov]no change G
JSON Path 语法介绍和使用场景
What are the ways to realize load balancing?
揭开服务网格~Istio Service Mesh神秘的面纱
273. Grading - acwing question bank [DP]
手册不全,如何手工刨出TongWeb的监控信息?
[dynamic programming] - longest ascending subsequence model
活动预告|Apache Doris x Apache SeaTunnel 联合 Meetup 开启报名!
Is it true that tongdaxin opens an account? Is it safe for tongdaxin to open an account?
Tencent cloud object storage operation process
Brief introduction of Bezier curve
Can ping command still play like this?
非凸优化问题经典必看综述“从对称性到几何性”,罗切斯特大学等
Homework for the third day of summer rhcsa training
【luogu P3220】与非(构造)(数位DP)(推论)
Redis source code and design analysis -- 4 Jump table