Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function roadRadar([speed, area]) {
- const speedLimit = {
- residential: 20,
- city: 50,
- interstate: 90,
- motorway: 130
- };
- const result = {
- 0: 'speeding',
- 1: 'excessive speeding',
- 2: 'reckless driving'
- }
- let speeding = speed - speedLimit[area];
- if (speeding > 0) {
- speeding = parseInt(speeding / 20.5);
- console.log(result[speeding] || result[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement