-2

I have tried finding an answer but they aren't exactly similar to the situation I'm in and I don't know how to apply them. I'm trying to run a function for only 233ms, but I don't know how to do this (sorry im a noob and just started java script). How would I do this?

mf2
  • 3
  • 1
  • 3
    Does this answer your question? [How to implement a "function timeout" in Javascript - not just the 'setTimeout'](https://stackoverflow.com/questions/8778718/how-to-implement-a-function-timeout-in-javascript-not-just-the-settimeout) This sounds like an XY problem, what's the actual issue you're trying to solve? – SuperStormer Feb 22 '21 at 00:10
  • 1
    If the timing has to be accurate then Javascript is not the tool to use. – Tangentially Perpendicular Feb 22 '21 at 00:11
  • 1
    What does the function do? Why does it take so long? Are you trying to limit the execution time of a function, or are you trying to repeat the execution so that it takes 233ms? – Bergi Feb 22 '21 at 00:11
  • You should show your existing cod and explain why it doesn't work. – user202729 Feb 22 '21 at 00:18

1 Answers1

-1

You could do a setTimeout for 233ms then have it clear the function from working when it is done.

setTimeout tutorial here https://www.w3schools.com/jsref/met_win_settimeout.asp

GtiClicker
  • 78
  • 8