html game script not running 3 lines of code

my html game script isnt running the last 3 lines of code its not alerting the alerts

    <script>
    var screen=prompt("◽◽");
    if(screen=="right")var screen2=alert("◾◽" + "n" + "You won!");
    alert("Level 2");
    var level2screen=prompt("◽◾◽");
    if(level2screen=="left")var level2screen2=prompt("◽◽◾");
    if(level2screen2=="right")alert("◽◾◽" + "n" + "You can't move anymore." + "n" + "You lost");
    if(level2screen2=="left")alert("◽◾◾" + "n" + "You won!");
    alert("Level 3");
    var level3screen=prompt("◾◽" + "n" + "◽◾");
    if(level3screen=="right")var level3screen2=prompt("◾◽" + "n" + "◾◽");
    if(level3screen=="up")var level3screen4=prompt("◽◽" + "n" + "◾◾");
    if(level3screen2=="right")var level3screen5=alert("◾◽" + "n" + "◾◾" + "n" + "You won!");
    if(level3screen2=="up")var level3screen3=alert("◾◽" + "n" + "◾◾" + "n" + "You won!");
    if(level3screen2=="left")alert("You can't move anymore" + "n" + "You lost");
    if(level3screen2=="down")alert("You can't move anymore" + "n" + "You lost");
</script>

Answer

I’m not all sure what logic you want, but the way your code is currently written “up” in level 3 is a logical dead end.

If you go "up" then you were saving the next direction in level3screen4 which isn’t used in the rest of your program.

I believe that in this line:

if (level3screen=="up") var level3screen4 = prompt("◽◽" + "n" + "◾◾");

You meant to do something like:

if (level3screen=="up") var level3screen2 = prompt("◽◽" + "n" + "◾◾");
//                                      ^ changed this

Again, you may need to change this to suit your goal.