From 5b2c9b856e164e176fbdabcf0ae963bf88e07273 Mon Sep 17 00:00:00 2001 From: vista-man <524715@vistacollege.nl> Date: Mon, 27 Jan 2025 20:17:35 +0100 Subject: [PATCH] Add number guessing game with HTML, CSS, and JavaScript implementation --- JavaScript/raad het getal/index.html | 17 +++++++++++++++++ JavaScript/raad het getal/raadgetal.js | 16 ++++++++++++++++ JavaScript/raad het getal/style.css | 26 ++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 JavaScript/raad het getal/index.html create mode 100644 JavaScript/raad het getal/raadgetal.js create mode 100644 JavaScript/raad het getal/style.css diff --git a/JavaScript/raad het getal/index.html b/JavaScript/raad het getal/index.html new file mode 100644 index 0000000..db10524 --- /dev/null +++ b/JavaScript/raad het getal/index.html @@ -0,0 +1,17 @@ + + + + + + Raad het getal + + + + +

Raad het getal

+

Voer een getal in tussen 1 en 100:

+ + +

+ + diff --git a/JavaScript/raad het getal/raadgetal.js b/JavaScript/raad het getal/raadgetal.js new file mode 100644 index 0000000..e8492f7 --- /dev/null +++ b/JavaScript/raad het getal/raadgetal.js @@ -0,0 +1,16 @@ +const targetNumber = Math.floor(Math.random() * 100) + 1; +let guess = null; + +function checkGuess() { + guess = parseInt(document.getElementById("guessInput").value, 10); + + if (guess < targetNumber) { + document.getElementById("result").innerText = "Te laag! Probeer het opnieuw."; + } else if (guess > targetNumber) { + document.getElementById("result").innerText = "Te hoog! Probeer het opnieuw."; + } else if (guess === targetNumber) { + document.getElementById("result").innerText = "Gefeliciteerd! Je hebt het juiste getal geraden."; + } else { + document.getElementById("result").innerText = "Ongeldige invoer. Voer een getal in tussen 1 en 100."; + } +} diff --git a/JavaScript/raad het getal/style.css b/JavaScript/raad het getal/style.css new file mode 100644 index 0000000..56ef62c --- /dev/null +++ b/JavaScript/raad het getal/style.css @@ -0,0 +1,26 @@ +body { + font-family: Arial, sans-serif; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 100vh; + background-color: #f0f0f0; + margin: 0; +} + +h1 { + color: #333; +} + +input, button { + padding: 10px; + margin: 5px; + font-size: 16px; +} + +#result { + margin-top: 20px; + font-size: 18px; + color: #555; +}