Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidystephenson/c923bcbcdaa34961b011b393f1df49b7 to your computer and use it in GitHub Desktop.

Select an option

Save davidystephenson/c923bcbcdaa34961b011b393f1df49b7 to your computer and use it in GitHub Desktop.
const theHobbit = {
author: 'Tolkien',
protagonist: 'Bilbo',
pages: 300
}
const theMatrix = {
budget: 63000000,
director: 'Wachowskis',
title: 'The Matrix'
}
const watchmen = {
author: 'Moore',
protagonist: 'Rorschach',
pages: 450,
}
const theGodfather = {
budget: 7200000,
director: 'Coppola',
title: 'The Godfather'
}
function analyze (data, key) {
const value = movie[key]
console.log('The', key, '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