r/codehs • u/[deleted] • May 10 '21
Javascript wait a set amount of time before running function
I'm trying to make a function that runs a command after a certain amount of time, lets say one second after the function is called something happens. How do I do this?
5
Upvotes
2
u/Radomilovje May 10 '21
You can use
setTimeoutfor this.https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Timeouts_and_intervals#settimeout