Created
May 12, 2021 03:54
-
-
Save pjcodesjs/d98f92def995cfbb2eaaaca072fde921 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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