let socket = io() let ourId; socket.on('gamers', gamers => { gamersUL.innerHTML = ''; for (let [id,gamer] of Object.entries(gamers)){ let el = document.createElement('li') el.innerHTML = gamer.ready && id != ourId ? `` : gamer.nick; el.children[0] && (el.children[0].onclick = () => socket.emit('start', {with: id})) gamersUL.appendChild(el) } }) socket.on('id', i => ourId = i) socket.on('hand', handData => console.log(handData)) const sendUpdate = ()=> socket.emit('hi', {nick: nick.value, ready: ready.checked}) hi.onclick = sendUpdate ready.onchange = sendUpdate