Your browser does not support JavaScript!
Upvotes Anonymous 0 User 0

The 'else' Statement in JavaScript

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.')
Was this helpful?


Leave a Comment

I agree to the Terms of Service
Design © 2015, Downranked, LLC.,
Original user code contributions under MIT License