Created
December 6, 2025 17:03
-
-
Save davidystephenson/58e2d3954fcaa6245f34a680c6c69a91 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <script> | |
| const grades = ['a', 'a', 'b', 'f', 'a', 'd', 'a', 'b', 'f'] | |
| for (let i = 0; i < grades.length; i++) { | |
| const grade = grades[i] | |
| console.log('traditional', grade) | |
| } | |
| for (const grade of grades) { | |
| console.log('of', grade) | |
| } | |
| // Array methods (callbacks) !important | |
| // function print (element) { | |
| // console.log('print', element) | |
| // } | |
| // grades.forEach(print) | |
| grades.forEach((grade) => { | |
| console.log('forEach', grade) | |
| }) | |
| const uppercaseGrades = grades.map(grade => { | |
| const upper = grade.toUpperCase() | |
| return upper | |
| }) | |
| console.log('uppercaseGrades', uppercaseGrades) | |
| const passingGrades = grades.filter(grade => { | |
| const passing = grade !== 'f' | |
| return passing | |
| }) | |
| console.log('passingGrades', passingGrades) | |
| const failing = grades.find(grade => { | |
| console.log('find grade', grade) | |
| return grade === 'f' | |
| }) | |
| console.log('failing', failing) | |
| const includesB = grades.includes('b') | |
| console.log('includesB', includesB) | |
| const includesC = grades.includes('c') | |
| console.log('includesC', includesC) | |
| const includesFive = grades.includes(5) | |
| console.log('includesFive', includesFive) | |
| console.log('grades', grades) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment