Ask coding questions

← Back to all posts
Error
WilliamXing (45)

I'm making this project for a friend. Why doesn't it work?

Answered by Coder100 (17045) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (17045)

Line 10: What's this?

function submit() {
  let random_num = Math.random(Math.floor() * 11)
  var submission = document.getElementById("submission").value; // Submission value
    
  if (submission == random_num) { 
    alert("Correct!");
  } else {
      alert("Wrong");
  }
}
Coder100 (17045)

you forgot to add the submit script tag lol

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

see that?

IcynDevz (765)

you need to make everything in the js file into a function. Then call the function in the submit button like:

<input type="submit" id="submit" onclick = "functionname()">

hope this helped :D

WilliamXing (45)

It says submit is not a function @IcingHackz