'How to restart game contents without reloading the page in javascript

For my snake game, I am trying to figure out how I can restart the game contents without reloading the page. Currently I am using window.location='/' to replay the game, but the issue is, when the page is refreshed the start screen loads.

Is there a simple way to reset/reload game contents without reloading the page?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source