Problem 27. Write a program using prompt function to take input of age as a value from the user and use alert to tell him whether he can drive! Use confirm to ask the user if he wants to see prompt again. Use console.error to log error if the age entered is negative.

const canDrive = (age)=> {
    return age>=18?true:false;
}
                  
let age = prompt(`Enter age`);
age = Number.parseInt(age);
                  
if (age < 0)
    console.error('age is negative');
else if (canDrive(age))
    alert(`hey buddy! you can drive`);
else
    alert(`you cannot drive`);

Output:

output output