Reputation: 89
So I'm trying to run a simple "conditional statement exercise" with a few questions, but in my Google Chrome it keeps giving me an error. Other applications aren't giving me any errors. I also have the most updated version of Google Chrome
Warning the js is going to launch when you go to the link
Check out my js fiddle
var counter = 0;
var questions = 5;
var ready = false;
alert("I have " + questions + " questions to ask you?");
var name = prompt("What is your name?");
alert("Hello " + name + "!");
alert("Here we go!");
var answer1 = prompt(name + "What color is the sky?");
if (answer1.toUpperCase() === 'BLUE') {
counter += 1;
alert('Congrates ' + name + ' you were right!');
} else {
alert('Sorry' + ' ' + name + 'but that was wrong.');
}
Upvotes: 2
Views: 6397
Reputation: 5647
I'm not seeing that error. You can try wrapping that conditional in a value check conditional:
var answer1 = prompt(name + "What color is the sky?");
if (answer1) {
if (answer1.toUpperCase() === 'BLUE') {
counter += 1;
alert('Congrates ' + name + ' you were right!');
} else {
alert('Sorry' + ' ' + name + 'but that was wrong.');
}
}
Upvotes: 5