Skip to content

Instantly share code, notes, and snippets.

@bgoonz
Created May 29, 2021 05:53
// creates a new variable 'counter' and set it's initial value to 0;
let counter = 0;
// creates a new function 'addOne' which takes 0 parameters
function addOne() {
// adds one to counter. Equivalent to counter = counter + 1;
counter++;
}
// calling a function. This executes the body of the named function.
addOne();
// prints our result to the console
console.log(counter);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment