Created
January 11, 2026 17:34
-
-
Save davidystephenson/2461aaf13a2333a1f92f9e4d7a0aa5da 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
| const theHobbit = { | |
| author: 'Tolkien', | |
| protagonist: 'Bilbo', | |
| pages: 300, | |
| title: 'The Hobbit' | |
| } | |
| const theMatrix = { | |
| budget: 63000000, | |
| director: 'Wachowskis', | |
| title: 'The Matrix' | |
| } | |
| const watchmen = { | |
| author: 'Moore', | |
| protagonist: 'Rorschach', | |
| pages: 450, | |
| title: 'Watchmen' | |
| } | |
| const theGodfather = { | |
| budget: 7200000, | |
| director: 'Coppola', | |
| title: 'The Godfather' | |
| } | |
| function analyze(media, key) { | |
| const value = media[key] | |
| console.log('The', key, 'of', media.title, 'is', value) | |
| return value | |
| } | |
| function formatString(value) { | |
| const formatted = value.toUpperCase() | |
| console.log(formatted) | |
| } | |
| function formatNumber(value) { | |
| const formatted = value.toFixed(2) | |
| console.log(`$${formatted}`) | |
| } | |
| const author = analyze(theHobbit, 'author') | |
| formatString(author) | |
| const director = analyze(theMatrix, 'director') | |
| formatString(director) | |
| const pages = analyze(watchmen, 'pages') | |
| formatNumber(pages) | |
| const budget = analyze(theGodfather, 'budget') | |
| formatNumber(budget) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment