# 7/14(三) 每日任務 https://hackmd.io/E0YGIY8PREytgQdTrmsqlA ###### tags: `JavaScript` `六角四週帶你掌握 Vue.js 必要觀念` 2021.7.15(Thu.) :::success ### ● 題目 **** forEach 情境題 >請使用 forEach 功能,將範例中 array 中超過 500 的值 push 進 newArray 中 >- 小提示: 會使用到 if() 功能,來做判斷 ```js const array = [100, 1500, 2000, 99, 499, 555, 1200] const newArray = [] ``` 參考: JS 陣列方法 [Youtube 影音](https://www.youtube.com/watch?v=_vFuDQ_6Xt8) ::: :::warning ## ● 答案: **** ```js const array = [100, 1500, 2000, 99, 499, 555, 1200] const newArray = [] array.forEach(function(el){ if (el > 500){ newArray.push(el) } }) console.log(newArray) ``` :::
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up