Im following Colt Steel’s web developer bootcamp and im at Todo List part 1, im wondering what does putting console.log() outside of while loop bellow it does? Does it stop and exit the loop? Since in code we didnt specify condition to be less than something?
Here’s the JS:
var todos = ["Buy New Turtle"];
var input = prompt("What would you like to do?");
while (input !== "quit") {
if (input === "list") {
console.log(todos);
} else if (input === "new") {
var newTodo = prompt("Enter new todo");
todos.push(newTodo);
}
var input = prompt("What would you like to do?");
}
console.log("OK, YOU QUIT THE APP");
Wouldnt it be a problem if last line was used very last inside of while loop and last input right before last console.log was used with else alone statement just after two if’s?
var todos = ["Buy New Turtle"];
var input = prompt("What would you like to do?");
while (input !== "quit") {
if (input === "list") {
console.log(todos);
} else if (input === "new") {
var newTodo = prompt("Enter new todo");
todos.push(newTodo);
} else {
var input = prompt("What would you like to do?");
}
console.log("OK, YOU QUIT THE APP");
}
putting var input = Prompt(What would you like to do?) inside of else statement doesnt make typing quit in prompt work. Why?
EDIT: Never mind i figured out its the same as incrementing a number each loop. My bad.