Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb6acce

Browse files
Updating question 35
1 parent c6439af commit cb6acce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,16 @@ for (var i = 0; i < arr.length; i++) {
12801280
}
12811281
```
12821282
1283+
This can also achieve by forEach (allows you to keep that variable within the forEach’s scope)
12831284
1285+
```javascript
1286+
var arr = [10, 32, 65, 2];
1287+
arr.forEach(function(i) {
1288+
setTimeout(function() {
1289+
console.log('The index of this number is: ' + i);
1290+
}, 3000);
1291+
})
1292+
```
12841293
12851294
## Question 36. How to check if the value of a variable in an array?
12861295

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /