Javascript Exercise – Demerit Points

 Demerit Points

 

//Speed Limit = 70
//5 -> 1 point
// Math.floor(1.3)
//12 points -> suspended

 

checkSpeed(110); // Enter speed here to check.

 

function checkSpeed(speed) {
const speedLimit = 70;
const kmPerPoint = 5;

 

if (speed < speedLimit + kmPerPoint) //Is current speed less then speed limit?
console.log(‘Ok’);
else {
const points = Math.floor((speed – speedLimit) / kmPerPoint); //Are points 12 or greater?
if (points >=12)
console.log(‘License suspended’);
else
console.log(‘Points’ , points); // Shows how many points person got.
}
}