Solution: Guess number



examples/js/guess_number.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">

  <title>Guess Number</title>
</head>
<body>

<input id="n">
<button id="go">Guess</button>

<div id="result"></div>

<script src="guess_number.js"></script>

</body>
</html>

examples/js/guess_number.js
"use strict";

var hidden = Math.round(Math.random()*200+0.5);
var counter = 0;
console.log(hidden);

function check_guess() {
    counter++;
    var n = Number(document.getElementById('n').value);
    var result = 'equal after ' + counter + ' guesses';
    if (n < hidden) {
        result = n + ' is less than our number';
    }
    if (n > hidden) {
        result = n + ' is greater than our number';
    }
    document.getElementById('result').innerHTML = result;
    return false;
}

document.getElementById('go').addEventListener('click', check_guess);