JSFiddle - React, Tailwind, and code Playground

by Lars Holm Jensen

HTML

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
	<title>CatanMath - a simple Catan Calculator</title>
  </head>
  <body>
    <h1>CatanMath</h1>
    <p>CatanMath is a simple blablabla</p>
    <form id="form">
      <input type="text" name="tall1" id="tall1" placeholder="Spot 1"/>
	  <input type="text" name="tall2" id="tall2" placeholder="Spot 2"/>
	  <input type="text" name="tall3" id="tall3" placeholder="Spot 3"/>
	  <p id="tall4"> </p>
	  <p id="tall5"> </p>
	  <p id="tall6"> </p>
	  <button type="submit">Send</button>
    </form>
	<p id="output"></p>
  <a href="https://www.colonist.io">Colonist.io, a free Catan website.</a>
  </body>
</html>

JavaScript

console.log('hello, developer!')
const form = document.getElementById('form')
form.addEventListener('submit', function(e) {
  // stopper nettsiden fra å laste inn på nytt
  e.preventDefault()
  console.log('', Sum_av_tretti_seks)
  var Sum_av_tretti_seks = 0
  var melding = "Du får ressurser "
  var melding2 = " av 36 kast. We hope you enjoyed CatanMath, if you wanna use it online we recommend:"
  const tall2 = document.getElementById('tall2').value
  const tall1 = document.getElementById('tall1').value
  const tall3 = document.getElementById('tall3').value
  console.log(tall1)
  var muligheter = []
  for (var i = 1; i < 7; i++) {
    for (var n = 1; n < 7; n++) {
      muligheter.push(i, n);
      if ((i + n == tall1) || (i + n == tall2) || (i + n == tall3)) {
        Sum_av_tretti_seks += 1
      }
    }
  }
  //console.log(x)
  const output = document.getElementById('output')
  //output.innerHTML = 'Du fikk ', (Sum_av_tretti_seks), "ut av 36"
  document.write(melding)
  document.write(Sum_av_tretti_seks)
  document.write(melding2)


})