As I delve into learning JS, I am currently experimenting with a classic and simple JS "game" akin to a "Choose Your Own Adventure." Within this process, I am tackling fundamental "if/else" statements in order to achieve the desired output:
'{Prompt/getUserInput} first -- Then {console.log}, THEN {prompt}, then {console.log}, etc.'
Despite my efforts, when inputting the code into repl.it, what I end up with is {prompt}{prompt}{prompt} followed by all the console logs. For clarification, here is a snippet to illustrate my point:
var buffer = function(){
console.log("------------------");
}
console.log("You are alone in the woods...");
buffer()
var userInput = prompt("You can either walk further into the woods or turn around. Please enter 'go on' or 'screw this'");
if(userInput === "go on"){
console.log("It is getting darker and darker. By the time you hear his heavy breathing behind you, it is too late");
}
if (userInput === "screw this"){
console.log("You always knew you were the only person in the village with a lick of sense. Now, where did you hide those bodies...");
}
buffer();
Is there a way to transform the sequence from being read as AAA.BBB to a more preferable A.B.A.B pattern?