How do I start animations after pressing a button 2D (Unity 5)

Pretty vague of a question but I can’t start animations when I press a button. It just simply doesn’t work. Here’s the test script (the one I’m currently using):
var anim: Animation;

function Update(){
	if(Input.GetKeyDown("w")){
		anim.IsPlaying("anim");
	}
}

@epikdude70alt

anim.IsPlaying will return a boolean value.

you need to make a animation controller, which will play an animation when certain button is clicked

https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/animate-anything