DEV Community

Discussion on: 🛠Refactoring: Replacing Conditional with Polymorphism

Collapse
jwhenry3 profile image
Justin Henry

I love converting conditionals to polymorphism, especially in reduced contexts:

const speeds = {
  african: 10,
  american: 7,
  european: 8
}
const bird = 'african'
const speed = speeds[bird]
Enter fullscreen mode Exit fullscreen mode