CodeChef is not very friendly to JavaScript

Describe your issue

I always get TLE (Time Limit Exceeded) when submitting in JavaScript, even though the time complexity is fine. But when I convert the code to C++, it gets accepted. I suspect it might be due to IO reasons. I hope you can help me with that.