-1
1.我在代碼的第一條評論中包含了我想要組合的兩條線。如果你能指出我需要做什麼,這真的會有所幫助。我幾天前剛開始使用JavaScript。如果你能推薦任何書籍,請告訴我。即時通訊正在閱讀murach系列書籍及其真正的幫助。如何結合這些特定的Javascript語句?
/*The two statements i want to combine are
entry = parseInt(entry);
var score1 = entry; */
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Average Test Scores</title>
<script>
var entry;
var average;
var total = 0;
//get 3 scores from user and add them together
entry = prompt("Enter test score");
entry = parseInt(entry);
var score1 = entry;
total = total + score1;
entry = prompt("Enter test score");
entry = parseInt(entry);
var score2;
total = total + score2;
entry = prompt("Enter test score");
entry = parseInt(entry);
var score3 = entry;
total = total + score3;
//calculate the average
average = parseInt(total/3);
</script>
</head>
<body>
<script>
document.write("<h1>The Test Scores App</h1>");
document.write("Score 1 = " + score1 + "<br>" +
"Score 2 = " + score2 + "<br>" +
"Score 3 = " + score3 + "<br><br>" +
"Average score = " + average + "<br><br>");
</script>
Thanks for using the Test Scores application!
</body>
</html>
'變種score1 = parseInt函數(條目); * /' – Rayon
目前還不清楚你的問題是什麼。通過合併這些線,你的意思是什麼? 'var score1 = parseInt(entry);'?爲什麼所有額外的代碼,而不僅僅是這兩行?我明白你有更具體的問題,你沒有直接問。 –
這是本書的練習。它告訴我以某種方式結合這兩條線。所以我只是發佈整個文件,以便大家可以看到。 –