简体   繁体   中英

Function not defined, even though I defined it

I'm making a game and a function that I defined says that it's not defined.

I looked and it said that the other person with the same issue had an extra ) somewhere but I looked and I don't have that problem.

I don't have anything extra that is not needed.

 <DOCTYPE html> <html> <head> <title>Programing Clicker</title> <style> h1{ color:#333; font-family:helvetica; font-weight: bold; font-size:2.5em; } h2{ font-size:2em; position: relative; left:250px; display: block; } h3{ font-size:1.75em; position: relative; left: 250px; display: block; } </style> </head> <body> <center> <h1>Programing Clicker</h1> <hr> </center> <h2>Skill</h2> <h3 id="skill_show"></h3> <h2>Money</h2> <h3 id = "moneyShow"></h3> <h2>Language</h2> <br> <br> <p id="timer"></p> <button onClick = "scriptMake()">Make a script</button> <script> var money = 1; var skill = 1; var language = 1; var scriptTime = 100/skill; var scriptTime2 = scriptTime; function scriptMake(){ for(var x = 100,x >= 0, x += skill){ document.getElementById("timer").innerHTML = x; } } setInterval( function showvars(){ document.getElementById("skill_show").innerHTML = skill; document.getElementById("moneyShow").innerHTML = money; },1 ) </script> </body>

your problem is here

for(var x = 100,x >= 0, x += skill){

You need semicolons instead of commas like so

for(var x = 100;x >= 0; x += skill){

Depending on which browser you are using to view the game, look up how to open the console in the browser. It will help you debug these things in a second.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM