To access EJS variable in JavaScript logic, we can inject the variable directly into the EJS template.
For instance, we write
<% if (gameState) { %>
<script>
let clientGameState = <%= gameState %>
</script>
<% } %>
to get the gameState
variable with <%= gameState %>
and assign that to the clientGameState
variable in the script tag.