Event if button is clicked as many times as you write in input

  html, javascript


<p>how many questions?<input type="text" id="questions"></p>
<button onclick="check()"> ok </button>
<div id = 'div'> </div>

    var text1
    let count = 0;
    var text1 = document.getElementById('questions').value;

    function check(){
      count = count + 1
      if (count === text1){
        alert(correct + '/' + text1);

This simple code is supposed to give an alert when the button is pressed the amount of times you wrote in the input. There is no error or something but the code just doesn’t work. Am I stupid and did I miss something or is the logic of my code just wrong? and how do make it work?

Source: Ask Javascript Questions