I made a html(ejs) button, that whenever clicked, it communicates with a node.js file and returns a randomly picked number. The first click works and returns a random number(eg 1). The problem is, in the next click, the button returns the same number(1) and continues to do so at all following clicks. Please how do I make the return value of this ejs function change at every click?
The index.ejs
<div style="width: 400px;height:80px;display:inline-block;">
<div onclick="calculateResult()">
Button //// Button is actually a div
</div>
</div>
<script type="text/javascript" >
alert('<%= calculateResult() %>')
</script>
The app.js(node.js)
app.locals.calculateResult = function(){
randomPick = Math.floor(Math.random() * 4)
return randomPick
}