Sense Space JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Random Sense and Room</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      text-align: center;
      margin-top: 100px;
    }
    button {
      font-size: 18px;
      padding: 10px 20px;
    }
  </style>
</head>
<body>
  <h1>Random Sense and Room</h1>
  <p id="sentence"></p>
  <button id="runButton">Run</button>

  <script>
    const senses = [
      "touch",
      "pressure",
      "itch",
      "cold thermoception",
      "heat thermoception",
      "proprioception",
      "tension",
      "stretch",
      "vibration",
      "nociception",
      "equilibrioception",
      "sound",
      "taste",
      "smell",
      "chemoreception",
      "time",
      "thirst",
      "hunger",
      "vision"
    ];

    const rooms = [
      "living room",
      "kitchen",
      "bedroom",
      "bathroom",
      "garage",
      "attic",
      "basement",
      "office",
      "library",
      "laundry room"
    ];

    function getRandomInt(min, max) {
      min = Math.ceil(min);
      max = Math.floor(max);
      return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    function generateSentence() {
      const randomSense = senses[getRandomInt(0, senses.length - 1)];
      const randomRoom = rooms[getRandomInt(0, rooms.length - 1)];
      const sentence = `How would you use ${randomSense} for a ${randomRoom}?`;
      document.getElementById("sentence").innerText = sentence;
    }

    document.getElementById("runButton").addEventListener("click", generateSentence);
    generateSentence();
  </script>
</body>
</html>
Published

Leave a comment