math.maxを使用せずに最高の変数を見つける方法を知りたいと思います。私のコードの私の目的は、ユーザーにゲームの質問をすることです。ユーザーは毎日ゲーム時間を入力してから、すべての時間を合計して平均し、その日に大半のゲームを表示します。 私はプログラミングに新しいです、どんな助けが良いです!ここで最高の変数を見つけて表示する
が私のコードで、これまでに...
function total() {
var th = Number(monday.value) + Number(tuesday.value) + Number(wednesday.value) + Number(thursday.value) + Number(friday.value) + Number(saturday.value) + Number(sunday.value);
alert("You gamed for " + th + " hours this week");
var ah = th/7;
alert("Your average is " + ah + " hours this week");
}
button.onclick = total;
\
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="draft.css">
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<title>The Gaming Hours Quiz</title>
<body>
<h1>The Gaming Hours Quiz</h1>
</body>
<p>Welcome to the Gaming Hours Quiz. Please fill out the neccesary information correctly to get your true results</p>
<h3 id="nametitle">What is your name?</h3>
<input id="name" type="letter" name="" value="type name here...">
<h3>How many hours have you gamed on Monday?</h3>
<input id="monday" type="number" name="" value="0">
<h3>How many hours have you gamed on Tuesday?</h3>
<input id="tuesday" type="number" name="" value="0">
<h3>How many hours have you gamed on Wednesday?</h3>
<input id="wednesday" type="number" name="" value="0">
<h3>How many hours have you gamed on Thursday?</h3>
<input id="thursday" type="number" name="" value="0">
<h3>How many hours have you gamed on Friday?</h3>
<input id="friday" type="number" name="" value="0">
<h3>How many hours have you gamed on Saturday?</h3>
<input id="saturday" type="number" name="" value="0">
<h3>How many hours have you gamed on Sunday?</h3>
<input id="sunday" type="number" name="" value="0">
<br>
<br>
<button id="button">Submit</button>
なぜMath.maxを使用したくないのですか? – miyamoto
@miyamoto、これはおそらく宿題です –
はい宿題です –