Advertisement
Todorov_Stanimir

06. Road Radar Last Decision

Sep 24th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function roadRadar([speed, area]) {
  2.     const speedObj = {
  3.         residential: 20,
  4.         city: 50,
  5.         interstate: 90,
  6.         motorway: 130,
  7.         0: 'speeding',
  8.         1: 'excessive speeding',
  9.         2: 'reckless driving',
  10.         toPrint: function (overSpeed) {
  11.             return result = this[parseInt(overSpeed / 20.5)] || this[2];
  12.         }
  13.     }
  14.     const speeding = speed - speedObj[area];
  15.     if (speeding > 0)
  16.         console.log(speedObj.toPrint(speeding));
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement