The code The HTML: Cow Pig Duck The JavaScript: function showSound() { var animal = this.id; if (animal === 'cow') { alert('Mooo'); } else { if (animal === 'pig') { alert('Oink'); } else { // must be a duck alert('Quack'); } } } function init() { document.getElementById('cow').onclick = showSound; document.getElementById('pig').onclick = showSound; document.getElementById('duck').onclick = showSound; } window.onload = init;