Need some help with this

var res, num, num2; 

next();    


function next(){
  while(!isGreaterThan0){    

    num = Math.floor(Math.random() * 10)+1;
    num2 = Math.floor(Math.random() * 10)+1;    

    res = num-num2;
    var isGreaterThan0 = res>0;
    if (isGreaterThan0){ 
      document.addEventListener("DOMContentLoaded", 
        function() {
          var i=0;
          while(i<10){
            document.getElementById("number").value = parseInt(prompt(num+ " - "+ num2+ " = "));
            i++;
            if(document.getElementById("number").value){
              check();
            }
          }    
      });

     function check()                                      
     const result = document.getElementById("number").value;   
    
     if(result == res ){
      next();
      alert("Toppen, helt rätt!");
      document.getElementById("number").value="";
    } else {  
     document.getElementById("number").value="";   
     alert("Fel, försök igen")
   }
  } 

Hello again. I have write this code, but when I try to run it it doesnt work. It say that something is wrong with line 30 ( cons result =) I have no idea what is wrong, couse when I run the code earlier it worked perfect, but now something is wrong?

anyone who knows?

I’ve tried to edit your post for readability.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

Also, please put this up somewhere like CodePen and explain what it’s supposed to do. If it’s just a few lines of code and there’s an obvious error, that can be easily fixed. If it’s something more complex, we are not magic. Often it will just be a syntax error or similar, but it is helpful to provide something more useful than just a big dump of unformatted code

Before the ‘const result =’ line, the line before, ‘function check()’ should have a ‘{’ after it.

So it would look like

function check()   {                                
     const result = document.getElementById("number").value;   
    
     if(result == res ){
      next();
      alert("Toppen, helt rätt!");
      document.getElementById("number").value="";
    } else {  
     document.getElementById("number").value="";   
     alert("Fel, försök igen")
   }
  }