Skip to content
← Back to Community
How do I define something in HTML?
Profile icon
BrandonKeele

Hello All, Keep in mind this is not my code, just a code example I was able to find on google to study from it and learn how to use it,

When I run the code it prompts this
"ReferenceError: cookieclick is not defined
at HTMLButtonElement.onclick (/:8:36)"
I've tried to define "cookieclick" but I don't know code all that well, I've looked it up and tried but with no success, here's the code below.

var cookies = 0;
var cursors = 0;
var buyCursor = 1;
var cookieclick = 1;

onClick="cookieclick(1)"

function cookieclick(number){
cookies = cookies + number;
};

document.getElementById("cookies").innerHTML = cookies;

onClick="buyCursor()"

Cursors:

Cost:

function buyCursor(){
var cursorCost = Math.floor(10 * Math.pow(1.1,cursors));
if(cookies >= cursorCost){
cursor
cursors = cursors + 1;

cookies = cookies - cursorCost; document.getElementById('cursors').innerHTML = cursors; document.getElementById('cookies').innerHTML = cookies; }; var nextCost = Math.floor(10 * Math.pow(1.1,cursors)); document.getElementById('cursorCost').innerHTML = nextCost;

};

window.setInterval(function(){

}, 1000);

cookieclick(cursors);

Voters
Profile icon
BrandonKeele
Comments
hotnewtop
Profile icon
Korbindev

yo wassup go to script.js, go the the bottom at line 153 and delete that line

Profile icon
ch1ck3n

rename script.js to main.js

Profile icon
BrandonKeele

@ch1ck3n Ill try that :)

Profile icon
BrandonKeele

@ch1ck3n just tried that and it prompts this now "SyntaxError: Unexpected token '<'
at /main.js:16:10
"

Profile icon
ch1ck3n

@BrandonKeele well you have a bug in your code

BY THE WAY THIS IS NOT VALID SYNTAX

image

Profile icon
BrandonKeele

@ch1ck3n How should I fix it? cause I dunno code that well enough to accurately fix code yet.