Last active
September 28, 2020 20:08
-
-
Save deathshadow60/72932df1003de520ab309701395f431c to your computer and use it in GitHub Desktop.
For/of and [] assignment, way better than foreach and faster than filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var | |
grades = [33, 90, 78, 94, 56, 88, 97], | |
passed = []; | |
for (var grade of grades) if (grade >= 70) passed[passed.length] = grade; | |
console.log(passed); // should output [ 90, 78, 94, 88, 97 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'll take for/of over foreach all day every day.