In this exercise I have a prompt where I want to require input. So if the user doesn't enter anything, it will ask again until a response is given. When a response is finally given it will go through the list of conditional statements. If a response is given on the first prompt it will simply go through that list of conditional statements. I can't seem to get this to work. What am I doing wrong here?
var question = prompt("What programming language are you currently learning?");
var questionUpper = question.toUpperCase();
var firstCap = question.charAt(0).toUpperCase() + question.slice(1).toLowerCase();
while (true) {
if (question === '') {
var test = prompt("Please enter a programming language.");
} else {
break;
}
if (questionUpper === 'HTML') {
alert(questionUpper + ' is a good language to start with.');
} else if (questionUpper === 'CSS') {
alert(questionUpper + ' helps HTML look good.');
} else if (firstCap === 'Javascript') {
alert(firstCap + ' is a fun language to learn after HTML and CSS.');
} else if (firstCap === 'Python') {
alert(firstCap + ' is a good language, too.');
} else {
alert("At least you're learning something.");
}
Aucun commentaire:
Enregistrer un commentaire