From 116d2434ee07bb5cae7c1650637ffc6718686daf Mon Sep 17 00:00:00 2001 From: LyntoAR Date: Sat, 5 Jun 2021 16:38:41 +0900 Subject: [PATCH] Create numcrundhdd.js --- numcrundhdd.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 numcrundhdd.js diff --git a/numcrundhdd.js b/numcrundhdd.js new file mode 100644 index 0000000..7728083 --- /dev/null +++ b/numcrundhdd.js @@ -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 = "もっと大きな数です"; + } + } + }