Sound on collision

How do I add a sound to something when the player collides with it? Can somebody please give me a script that will let me do this. I prefer Javascript, and please make sure the script doesn’t have any errors (those annoy me to death!). Thanks much!

This is not a script but a basic idea of what the structure should look like:

if (//player touches gameObject) {
 AudioSource audio = GetComponent<AudioSource>();
 audio.Play(//sound you want to play);
}