Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save davidystephenson/fcea30beee18c014c7f56dec0122e5d9 to your computer and use it in GitHub Desktop.
const alpha = {
budget: 63000000,
director: 'Wachowskis',
title: 'The Matrix'
}
const beta = {
budget: 7200000,
director: 'Coppola',
title: 'The Godfather'
}
function analyzeMovie (movie, key) {
const value = movie[key]
console.log('The', key, 'of', movie.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 = analyzeMovie(alpha, 'budget')
formatNumber(budget)
const director = analyzeMovie(beta, 'director')
formatString(director)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment