Help with addition of variables


#1

// Check if the user is ready to play
confirm("ready to play!")
var bal = 1000
var run = function() {
    var computerChoice = Math.random()
    console.log(computerChoice)
    if (computerChoice < .50) {
        computerChoice = 1
        console.log(computerChoice)
    } else {
        computerChoice = 2
        console.log(computerChoice)
    }
    var userChoice = prompt("pick a number 1-2")
    console.log(userChoice)
    var bet = prompt("what do you bet")
    if (userChoice === computerChoice) {
        bal = bal + bet

    } else {
        bal = bal - bet
    }
    confirm("your balance is" + bal)
    run()
}
run()

#2

my problem is if you run this, you can see what the computer choice was, you can then pick what the computer chose but when you chose a balance your balance will lose the bet even if you won please help


#3

try running it yourself if you cant figure out what the problem is


#4
  1. You can see what the computer's choice is because you log it.

  2. Many of your curly braces aren't balanced.

  3. Please format your code.