I want to make each button call a function called sDM() and input a different code but whenever I do this, I get:
ReferenceError: sDM is not defined at HTMLButtonElement.onclick
<button onclick="sDM(38)" style="width: 100%">↑</button>
<br>
<button onclick="sDM(37)" style="width: 47%">←</button>
<button onclick="sDM(39)" style="width: 47%">→</button>
<br>
<button onclick="sDM(40)" style="width: 100%">↓</button>
My function:
function sDM (dN) {
snake.setDirection(directions[dN])
}