The course is Pass the technical interview with Javascript, the chapter is Javascript Linear Data Structure (section Stacks), and the project is Web navigator. During the User Interface Part 1 there is a variable finish which is set to false, and then the while loop should (for the purpose of a simple user interface) console.log(instructions) while finish is false:
let finish = false;
let showBack = false;
let showNext = false;
showCurrentPage('DEFAULT: ');
while(finish === false){
let instructions = baseInfo;
if(backPages.peek() != null){
instructions = ${instructions}, ${backInfo}
;
showBack = true;
} else {
showBack = false;
}
if(nextPages.peek() != null){
instructions = ${instructions}, ${nextInfo}
;
showNext = true;
} else {
showNext = false;
}
instructions = ${instructions}, ${quitInfo}
;
console.log(instructions);
}
And then in logged instructions should be an option for user to quit the program by setting finish to true which should terminate this while loop. How can this be a good practice? The while loop goes infinitely because finish is always false! It should be true only when user quits the program which is an option he should get with this while loop, which is set to go until the end of the world because the finish is false and it will always be false until the user quits the program which is an option he should get with this while loop, which is set to go until… (?). What am I missing here?