+ 1

Why is the fps & interval NaN?[SOLVED]

Everything seems fine but the fps is NaN and so is the interval. Why is this happening? https://code.sololearn.com/WwweLFkgnbOG/?ref=app

26th Dec 2021, 10:39 AM
Bhaveshsingh Pawar
Bhaveshsingh Pawar - avatar
2 Respostas
+ 6
Change line 31: interval = (Date.now()-t)/1000; NaN usually arises when some math operation fails. In this case, you passer the Date.now method into a subtraction operation with t which does not work.
26th Dec 2021, 10:56 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
👑 Prometheus 🇸🇬 thank you, I was missing () after the Date.now method. Now it works fine.
26th Dec 2021, 12:08 PM
Bhaveshsingh Pawar
Bhaveshsingh Pawar - avatar