I am trying to access a variable inside a function.
Here is my code:
<div id="box1" class="box" onclick="set(1)"></div>
let i = 0;
i = number;
Console Log Output: [When i click my div]
The only time you call
console.log it will output
0 and that is the log output before you click the div.
If you want to get the output when you click the div then the
console.log statement must be inside the event handler function.