JavaScript语法错误 - 无法识别的令牌

时间:2013-10-15 19:09:14

标签: javascript

当我尝试运行代码时出现以下错误:SyntaxError:无法识别的标记'\'

我是JavaScript新手,这是我的第一个项目。我想在Code Academy中运行它。当我尝试在Mac的“Coderunner”应用程序中运行它时,会收到一条错误,说“提示未定义”

以下是我的基本GPA计算器代码:

//GPA CALCULATOR 


var classOneprompt = prompt("Enter class one grade, ex. A, B, C, etc.");
var classTwoprompt = prompt("Enter class two grade");
var classThreeprompt = prompt("Enter class three grade. If you do not have a third class enter none.")
var classFourprompt = prompt("Enter class four grade. If you do not have a fourth class enter none.")
var classFiveprompt = prompt("Enter class Five grade. If you do not have a fifth class enter none.")
var classSixprompt = prompt("Enter class Six grade. If you do not have a sixth class enter none.")

if (classOneprompt === "A")
    {var classOne = 4.0}
else if (classOneprompt === "B")
    {var classOne = 3.0}
    else if (classOneprompt === "C")
    {var classOne = 2.0}
    else if (classOneprompt === "D")
    {var classOne = 1.0}
    else if (classOneprompt === "F")
    {var classOne = 0.0}
    else if (classOneprompt = "none")
    {var classOne = null}

if (classTwoprompt === "A")
    {var classTwo = 4.0}
else if (classTwoprompt === "B")
    {var classTwo = 3.0}
    else if (classTwoprompt === "C")
    {var classTwo = 2.0}
    else if (classTwoprompt === "D")
    {var classTwp = 1.0}
    else if (classTwoprompt === "F")
    {var classTwo = 0.0}
    else if (classTwoprompt === "none")
    {var classTwo = null} 

if (classThreeprompt === "A")
    {var classThree = 4.0}
else if ( classThreeprompt === "B")
    {var classThree = 3.0}
     else if (classThreeprompt === "C")
    {var classThree = 2.0}
    else if (classThreeprompt === "D")
    {var classThree = 1.0}
    else if (classThreeprompt === "F")
    {var classThree = 0.0}
    else if (classThreeprompt === 'none')
    {var classThree = null}


if (classFourprompt === "A")
    {var classFour = 4.0}
else if ( classFourprompt === "B")
    {var classFour = 3.0}
    else if (classFourprompt === "C")
    {var classFour = 2.0}
    else if (classFourprompt === "D")
    {var classFour = 1.0}
    else if (classFourprompt === "F")
    {var classFour = 0.0}
    else if (classFourprompt === "none")
    {var classFour = null}


if (classFiveprompt === "A")
    {var classFive = 4.0}
else if ( classFiveprompt === "B")
    {var classFive = 3.0}
    else if (classFiveprompt === "C")
    {var classFive = 2.0}
    else if (classFiveprompt === "D")
    {var classFive = 1.0}
    else if (classFiveprompt === "F")
    {var classFive = 0.0}
    else if (classFiveprompt === "none")
    {var classFive = null}


if (classSixprompt === "A")
    {var classSix = 4.0}
    else if (classSixprompt === "B")
    {var classSix = 3.0}
    else if (classSixprompt === "C")
    {var classSix = 2.0}
    else if (classSixprompt === "D")
    {var classSix = 1.0}
    else if (classSixprompt === "F")
    {var classSix = 0.0}
    else if (classSixprompt === "none")
    {var classSix = null}

if (classOne != null && classTwo != null)
    {console.log((classOne + classTwo) / 2)}
    else if (classOne != null && classTwo != null && classThree != null)
    {console.log((classOne + classTwo + classThree) / 3)}
    else if (classOne != null && classTwo != null && classThree != null && classFour != null)
    {console.log((classOne + classTwo + classThree + classFour) / 4)}
    else if (classOne != null && classTwo != null && classThree != null && classFour != null && classFive != null)
     {console.log((classOne + classTwo + classThree + classFour + classFive) / 5)}
    else if (classOne != null && classTwo != null && classThree != null && classFour != null && classFive != null && classSix != null)
     {console.log((classOne + classTwo + classThree + classFour + classFive + classSix) / 6)}
    else 
     {console.log("Uh Oh! Looks like there was a mistake. Please try again and make sure you follow instructions carefully! Good luck!")}

0 个答案:

没有答案