這是我第一次使用這個網站尋求幫助,但我想知道爲什麼我的代碼沒有運行。我是一年級學生,因此徹底心煩意亂!任何幫助將不勝感激,並提前感謝。我對格式化表示歉意(我很難在本網站的代碼片段編輯器中修復它)。編程任務
<html>
<head>
<meta charset ="UTF-8"/>
</head>
<body>
<script>var firstPerson = prompt(""Enter the full name of the first person:")</script>
\t <script>var secondPerson = prompt(""Enter the full name of the second person:")</script>
\t <script>var thirdPerson = prompt(""Enter the full name of the third person:")</script>
\t <script>var fourthPerson = prompt(""Enter the full name of the fourth person:")</script>
\t <script>var fifthPerson = prompt(""Enter the full name of the fifth person:")</script>
\t <script>alert("\"\\nThe \\nFirst\\n Person is ".concat("'", firstPerson, "'", "\\n\"\n\'\\nThe \\nSecond\\n Person is ",
'"', secondPerson, '"', "\\n\'\n\"\\nThe \\nThird\\n Person is ", '"', thirdPerson, '"', "\\n\"\n\'\\nThe \\nFourth\\n Person is ",
\t "'", fourthPerson, "'", "\\n\'\n\"\\nThe \\nFifth\\n Person is \\", fifthPerson, "\\", "\\n\""))</script>
\t <script>document.write("First Person: ".concat(firstPerson))</script>
\t <script>document.write("First person (last name, first name): ".concat(firstPerson.substring(5,14), ", ", firstPerson.substring(0, 4)))</script>
\t <script>document.write("Second Person: ".concat(secondPerson))</script>
\t <script>document.write("Second person (last name, first name): ".concat(secondPerson.substring(6,10), ", ", secondPerson.substring(0, 5)))</script>
\t <script>document.write("Third Person: ".concat(thirdPerson))</script>
\t <script>document.write("Third person (last name, first name): ".concat(thirdPerson.substring(6,11), ", ", thirdPerson.substring(0, 5)))</script>
\t <script>document.write("Fourth Person: ".concat(fourthPerson))</script>
\t <script>document.write("Fourth person (last name, first name): ".concat(fourthPerson.substring(6,12), ", ", fourthPerson.substring(0, 5)))</script>
\t <script>document.write("Fifth Person: ".concat(fifthPerson))</script>
\t <script>document.write("Fifth person (last name, first name): ".concat(fifthPerson.substring(6,10), ", ", fifthPerson.substring(0, 5)))</script>
\t <script>document.write("All of the first names are: ".concat(firstPerson.substring(0,4), ", ", secondPerson.substring(0,5), ", ", thirdPerson.substring(0,5),
", ", fourthPerson.substring(0,5), ", ", fifthPerson.substring(0,5)))</script>
\t <script>document.write("All of the last names are: ".concat(firstPerson.substring(5,14), ", ", secondPerson.substring(6,10), ", ", thirdPerson.substring(6,11),
\t ", ", fourthPerson.substring(6,12), ", ", fifthPerson.substring(6,10)))</script>
</body>
</html>
身體裏有什麼?我看到的只是腳本 – makdu
首先,您不需要將每行代碼放在'script'標記中,嘗試在腳本標記中包含'type ='text/javascript'',您的*一個*腳本標記。我會看看我可以用你的代碼做什麼。 –
按F12,單擊控制檯,清除結果並再次運行您的代碼段。這些錯誤將是一個開始的好地方。 – Gary