Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create numcrundhdd.js #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions numcrundhdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 数当てゲーム
let min = 1;
let max = 100;
let num = Math.floor(Math.random() * (max + 1 - min)) +min;

window.onload = function onload(){

var textbox = document.getElementById('randomNumberI').value;
// console.log(randomNumberI.value);

}

function judge() {

let flag = 0;
if(isNaN(randomNumberI.value)){
flag = 1;
}

if(flag){
window.alert("数字を半角で入力してください。");
} else {

var answerJ = document.getElementById("output")


let inputNumber = document.getElementById('randomNumberI').valueAsNumber;
if (num == inputNumber) {
answerJ.innerHTML = "正解!";
} else if (num < inputNumber) {
answerJ.innerHTML = "もっと小さな数です";
} else {
answerJ.innerHTML = "もっと大きな数です";
}
}
}