I'm fairly new to JavaScript and I've encountered a problem. The issue is that the prompt in my code doesn't update with the correct values, while the 'console.log' function does for some reason. I'm really curious as to why this happens and if there's a way to make the prompt update like the 'console.log' function does. I've attempted to rearrange the positions of the variables in the code, but since I'm not an expert, I'm unsure if the variable positions were ever correct.
Any help would be greatly appreciated. Please let me know if anything is unclear!
var alive = true;
var destinationArray = ["town ", "areas ", "bosses"];
var destinationArraySet = 1;
var allDestination = destinationArray.slice(0, destinationArraySet).join(' ').trim();
var userDestinationPrompt = ("Where would you like to go? Available places: \n" + allDestination +".");
var userDestination = function () {
allDestination = destinationArray.slice(0, destinationArraySet).join(' ').trim();
console.log(allDestination);
userDestinationAnswer = prompt(userDestinationPrompt).toUpperCase();
destinationArraySet++;
};
while (alive) {
userDestination();
}