Without actually knowing what your test is on and what you've already learned/supposed to have learned, I don't know exactly how to do that.
Where is the password coming from? I'll assume a basic level of JS tutoring, and the following is a function that may work (although the password could be revealed by viewing the source).
And I'm not sure how you would've been told how to 'direct to a page', so I've put a little comment where you need to add that bit.
Code:
<script type='text/javascript'>
function get_password() {
var count = 0;
var pass = 'Teh Paszw0rd!';
var guessed = 0;
while ((count < 3) && (guessed == 0)) {
var input = window.prompt('What is the password?','');
if (input == pass)
guessed = 1;
count++;
}
if (guessed == 1) {
// direct to 'good' page
}
else {
// direct to 'bad' page
}
}
</script>