Skip to content

Instantly share code, notes, and snippets.

@pjcodesjs
Created May 12, 2021 03:54
Show Gist options
  • Save pjcodesjs/d98f92def995cfbb2eaaaca072fde921 to your computer and use it in GitHub Desktop.
Save pjcodesjs/d98f92def995cfbb2eaaaca072fde921 to your computer and use it in GitHub Desktop.
const error_handler = (property) => {
throw new Error(`Error: ${property} is required!`);
}
const monitor_roads = (car=error_handler('Car'), speed=error_handler('Speed')) => {
console.log(`Your ${car} was going at a speed of ${speed}mph.`);
}
monitor_roads('Ferrari', 240); // Your Ferrari was going at a speed of 240mph.
monitor_roads('Ferrari'); // Error: Speed is required!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment