If we'd like to give other users (not Jim or Tom) a message, we can use the else statement:
if(username == 'Jim') {
alert('Welcome Jim')
} else if(username = 'Tom') {
alert('Sorry Tom, you are not authorized to view this page.')
} else {
alert('Sorry, you are not Jim or Tom.')
}
Next: Commenting in JavaScript
Leave a comment