Unanswered question

How can i code for a timer function in Javascipt to know how long a loop was executed?

I have an if..else condition in my javascript and I want to include a timer function in the else loop to know how long it took for that part to be executed. How can I achieve this?

Sweta N.
Sweta N.

Sweta N.

Level
0
3 / 100
points

Answers

Neil W.
Neil W.

Neil W.

Level
4
5000 / 5000
points
Team

I'm not sure I follow, you mention else loop? You could store the time stamp in a variable, do some actions then store a second time stamp calculate the difference. Why are you timing the code though?