Skip to content

Instantly share code, notes, and snippets.

@mearns
Last active November 13, 2018 18:45
Show Gist options
  • Save mearns/22d7c4e65f852b06bc00d31ea4d041ad to your computer and use it in GitHub Desktop.
Save mearns/22d7c4e65f852b06bc00d31ea4d041ad to your computer and use it in GitHub Desktop.
const dayNamesInOrder = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
const daysOfTheWeek = dayNamesInOrder.reduce((obj, dayName, index) => {
obj[dayName] = index
return obj
}, {})
const studentGradeCache = studentNames.reduce((cache, studentName) => {
cache[studentName] = lookupStudentGrade(studentName)
return cache
}, {})
const perfectSquaresMemo = [
0, 1, 2, 3, 4, 5, 6
].reduce((memo, input) => {
memo[input] = input * input
return memo
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment