Skip to content

Instantly share code, notes, and snippets.

@wongjiahau
Last active July 3, 2019 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wongjiahau/d9e6a9276cccdf61b850b9f57ff174d0 to your computer and use it in GitHub Desktop.
Save wongjiahau/d9e6a9276cccdf61b850b9f57ff174d0 to your computer and use it in GitHub Desktop.
const getArea = (shape: Shape) => {
switch(shape.label) {
case 'circle': return Math.PI * Math.pow(shape.radius, 2)
case 'triangle': return 0.5 * shape.base * shape.height
case 'rectangle': return shape.height * shape.width
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment