Skip to content

Instantly share code, notes, and snippets.

@tudorilisoi
Last active March 1, 2021 11:51
Show Gist options
  • Save tudorilisoi/7a17fb454ca3689e68c6336b4c14eafd to your computer and use it in GitHub Desktop.
Save tudorilisoi/7a17fb454ca3689e68c6336b4c14eafd to your computer and use it in GitHub Desktop.
let num = 0 //declare a variable whose initial value is zero
//function declaration
function increaseNum(){
num++ //increase the value of num by 1 using the increment operator
//get the reference to the body element
let bodyElement = document.getElementsByTagName('body')[0]
//... and set its text value to the value of num
bodyElement.innerText = num
}
//run my increaseNum function at most every 1000 milliseconds (could be later)
window.setInterval(increaseNum, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment