Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
What we will do is that we will consolidate all alert() statements into one function. We can pass a parameter to that function so that we can change the messages in the alert box depending on the situation.
Go back to your code, and define the following function at the top of your<script> tag:
function alertMessage(messageObject) {
alert(messageObject);
return true;
}
messageObject is the parameter that we will use to hold our message.
Now, change all alert() statements to alertMessage() such that the message for alert() is the same as alertMessage(). Once you are done, save the file and run the code in JSLint again.