0

When I try to run this code, I get this syntax error:

Uncaught syntax error: Unexpected end of input

I have been trying to debug this for about 20 mins, but I can't find the error. Could someone help me with this? I'm pretty sure the error is below line 26, because testing it yesterday, it worked up to that line, then there was minor debugging I had to work on. But it could be a simple parentheses or curly bracket error that I just can't see.

Code:

 var age = prompt("How old would you like you're character to be?")
if(age < 0) {
    age = prompt("Your character is too young, please choose a number between 1 and 100.")
     }
if(age > 100) {
    age = prompt("Your character is too old, please choose an age between 1 and 100.")
    }
if(age < 0) {
    age = 50
    }
if(age > 100)
    age = 50)
    }
var randomString = " Years old"
confirm("Your character is now " +age +randomString)
var job = prompt("Choose a job, insert the number into the text box to choose.     1)Teacher  2)Veteranarian  3)Doctor  4)FireFighter  5)Carpenter  6)Driver  7)Chef  8)Accountant  9)Lawyer  10)Mason")
    if(job > 10) {
    var job = prompt("You chose an invalid job, please choose another one. Choose a job, insert the number into the text box to choose.     1)Teacher  2)Veteranarian  3)Doctor  4)FireFighter  5)Carpenter  6)Driver  7)Chef  8)Accountant  9)Lawyer  10)Mason")
    }
if(job < 1) {
    var job = prompt("You chose an invalid job, please choose another one. Choose a job, insert the number into the text box to choose.     1)Teacher  2)Veteranarian  3)Doctor  4)FireFighter  5)Carpenter  6)Driver  7)Chef  8)Accountant  9)Lawyer  10)Mason")
    }
var randomIncome = Math.floor(Math.random()*150001)
var randomVariable = " Press 'OK' to keep this income, or 'Cancel' to recieve you're jobs specified income."
var randomOrNot = confirm("Your randomly generatod income is $" +randomIncome +randomvariable)
if(randomOrNot === true) {
    var income = randomIncome
    }
else {
    if(job === 1) {
        var income = 45000
        var bankMoney = 450000
        }
    if(job === 2) {
        var income = 50000
        var bankMoney = 500000
        }
    if(job === 3) {
        var income = 125000
        var bankMoney = 1250000
        }
    if(job === 4) {
        var income = 35000
        var bankMoney = 350000
        }
    if(job === 5) {
        var income = 40000
        var bankMoney = 400000
        }
    if(job === 6) {
        var income = 20000
        var bankMoney = 200000
        }
    if(job === 7) {
        var income = 30000
        var bankMoney = 300000
        }
    if(job === 8) {
        var income = 95000
        var bankMoney = 950000
        }
    if(job === 9) {
        var income = 120000
        var bankMoney = 1200000
        }
    if(job === 10) {
        var income = 75000
        var bankMoney = 750000
        }
    }
confirm("Your income is now $" +income)
confirm("Your bank balance is now $" +bankMoney)
var carCrash = Math.floor(Math.random()*50001)
if(carCrash > 15000) {
    confirm("You were in a car crash, the damages costed you $25,000.")
    bankMoney = bankMoney - 25000
    }
else {
    confirm("You swerved to avoid a car crash on your way home from work. You were given a trafic ticket that costed $250.")
    bankMoney = bankMoney - 250
    }
var withdrawl1 = prompt("How much money would you like to withdrawl from your bank account? (withdrawls are taxed 9%) Your current balance is : $" +bankMoney)
var pocketMoney = withdrawl1 - withdrawl1 * 0.09
bankMoney = bankMoney + income
confirm("You recieved pay. Your new bank balance is : $" +bankMoney)
1
  • Not sure where the error is but it's always a good habit to use semicolon at the end of command; Commented Nov 28, 2014 at 13:52

2 Answers 2

2

I think error is :

if(job === 3) {
    var income = 125000
    var bankMoney = 1250000
    {

should be

if(job === 3) {
    var income = 125000
    var bankMoney = 1250000
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, can't believe I didn't see that edit: There's something else somewhere... Ill update it though
0
if(age > 100)
    age = 50)
    }

missing open {

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.