How to replace value 1 by the variable x when setting an onclick function to a td like below:
var sounds = [1, 3, 8, 12];
var x = 123;
mytd.onclick = () => play(sounds[1].toString());
>Solution :
Perhaps you want "currying"?
var sounds = [1, 3, 8, 12];
const playSound = (snd) => () => play(sounds[snd].toString());
var x = 123;
mytd.onclick = playSound(x)