Advertisement
Guest User

RoadRadar2

a guest
Aug 29th, 2020 (edited)
947
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve([speed, area]) {
  2.     let allowedSpeeds = {
  3.         'motorway': 130,
  4.         'interstate': 90,
  5.         'city': 50,
  6.         'residential': 20
  7.     }
  8.     if (speed > allowedSpeeds[area]) {
  9.         let speeding = speed - allowedSpeeds[area];
  10.         logSpeeding(speeding);
  11.     }
  12.  
  13.     function logSpeeding(speeding) {
  14.         if (speeding <= 20) {
  15.             console.log('speeding');
  16.         } else if (speeding <= 40) {
  17.             console.log('excessive speeding');
  18.         } else {
  19.             console.log('reckless driving');
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement