1//Basic variables (the currency in this example is lemons)
2var incrementInterval = 10 //This is done so the code in the setInterval function runs 10 times per second
3var lemons = 0.0
4var lemonsPerClick = 1.0
5var lemonsPerIncrement = 0.0
6
7//Function for clicking to get lemons
8function addLemons() {
9 lemons += lemonsPerClick
10 updateLemons()
11}
12
13//Function for updating the lemon counter
14function updateLemons() {
15 document.getElementById("lemonCounter").innerHTML = `Lemons: ${Math.floor(lemons)}`
16}
17
18//Function that returns the target's value if it were to be divided into 1 second relative to milleseconds
19function incrementValue(target) {
20 return target / (1000 / (incrementInterval * 10)) //Target divided by one second
21}
22
23//Function that runs the following code repeatedly (function, milleseconds before running again)
24setInterval(function() {
25 lemons += incrementValue(lemonsPerIncrement)
26 updateLemons()
27}, incrementInterval * 10)