Help me with my game not a lesson

so i am making a game and it has so many errors i don’t know how to fix

<!DOCTYPE html>
		<title>Page Title</title>
		   var dead = false
		    var pickup = "Null"
		    var direction = "null"
		    if (direction = "null"){
		        document.write("go to a1 or b1")
		    var direction = prompt("go to a1 or b1")
		    if (direction = "a1"){
		        document.write(" you found a sword pick it up? ")
		    var pickup = prompt("pick up the sword?")
		    if (pickup = "yes"){
		        document.write("You ran into a goblin")
		 alert(" you ran into a goblin you killed it with the sword")
		        var dead = false
		    if (pickup = "no" ){
		        var dead = true
		    if (dead = true){
		        alert("you died")

this is my code

Page Title



		    var pickup = "Null"
		    var direction = "null"

why use string null, why not actual null?

= is assignment operator, although it is possible to use assignment operator in a conditional statement, is it desired here?

i dunno this is my first time coding a game from js or any code can you tell me what i need to do i’ve spent around 3 hours trying to fix this bug

i’ll describe the issue so it prompts me to type a1 or b1 and if i type a1 when b1 is a thing both will execute

doesn’t matter what you type/input, the condition will simple be always true.


 if (direction = "a1")

you use an assignment operator (should be a comparison operator), by using assignment, the string will be assigned to the variable and then be evaluated as truthy.