Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function roadRadar(input) {
- let limits = {
- 'motorway': x => 130 - x,
- 'interstate': x => 90 - x,
- 'city': x => 50 - x,
- 'residential': x => 20 - x
- }
- let speedingUp = {
- 'less': '',
- 20: 'speeding',
- 40: 'excessive speeding',
- 'more': 'reckless driving'
- }
- let speed = Number(input[0]);
- let area = input[1];
- let diff = limits[area](speed);
- function speeding(diff) {
- return diff >= 0 ? speedingUp['less'] :
- diff >= -20 ? speedingUp[20] :
- diff >= -40 ? speedingUp[40] : speedingUp['more']
- }
- console.log(speeding(diff));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement