Created
January 11, 2026 17:40
-
-
Save davidystephenson/8e73878a20a35fb0b28b14b788a5f047 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 media = { | |
| theGodfather: { | |
| budget: 7200000, | |
| director: 'Coppola', | |
| title: 'The Godfather' | |
| }, | |
| theHobbit: { | |
| author: 'Tolkien', | |
| protagonist: 'Bilbo', | |
| price: 20, | |
| title: 'The Hobbit' | |
| }, | |
| theMatrix: { | |
| budget: 63000000, | |
| director: 'Wachowskis', | |
| title: 'The Matrix' | |
| }, | |
| watchmen: { | |
| author: 'Moore', | |
| protagonist: 'Rorschach', | |
| price: 30, | |
| title: 'Watchmen' | |
| }, | |
| } | |
| function analyze(mediaKey, valueKey) { | |
| const data = media[mediaKey] | |
| const value = data[valueKey] | |
| console.log('The', valueKey, 'of', data.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 budget = analyze('theGodfather', 'budget') | |
| formatNumber(budget) | |
| const author = analyze('theHobbit', 'author') | |
| formatString(author) | |
| const director = analyze('theMatrix', 'director') | |
| formatString(director) | |
| const pages = analyze('watchmen', 'price') | |
| formatNumber(pages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment