gpt4 book ai didi

syntax - Javascript语法错误: unexpected end of input

转载 作者:行者123 更新时间:2023-12-03 08:22:05 25 4
gpt4 key购买 nike

当我尝试运行此代码时,出现以下语法错误:

Uncaught syntax error: Unexpected end of input

我已经尝试调试了大约20分钟,但是我找不到错误。有人可以帮我吗?我很确定该错误在第26行以下,因为昨天进行了测试,直到该行为止,然后我不得不进行一些小的调试。但这可能是我看不到的简单括号或大括号错误。

码:
 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)

最佳答案

我认为错误是:

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

should be

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

关于syntax - Javascript语法错误: unexpected end of input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27190067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com