play audio only once in html page
This question maybe out of scope in sololearn but, i have received numerous helps here in sololearn so, i just want to ask here in hopes of getting some answers so please dont mind. So, what i am doing is I have a table 9x10 matrix numbered from 1 to 90. I am randomly picking a random each 5 seconds and gives that random number to the javascript. What i want to do is i want to update the cell color of the table that contains the random number and play and audio of the chosen number. I am able to change the cells color but my audio plays more then a thousand time in one second so it gives an effect like an echo so how can i solve this. ? The problem is that the javascript function that checks the random number in the table is called non stop so even if i set a variable 'count' to set it to 1 when the audio plays for the first time and put a condition to skip playing the audio if the condition doesn't apply, it doesnt work because the method or the function that check and plays the audio gets called everytime and the variable count is set back to its initial initialised number. Can i use cookies or session to store the number thats being randomly picked and use that to validate and play the audio only once ? Here is the link to the javascript and the table https://code.sololearn.com/WW55HmueD8al