How to dynamically create a cube and color it?

I am a week into Unity and am confused about coloring a dynamic cube in javascript. I’ve been searching for over 2 hours and can’t grasp the right way to do so. I know in logic I have to create the material and give it a color but, I don’t know how to assign it to a dynamic cube. I was only able to create a cube for now:

function Start () {
	var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
	cube.name = 'brown_cube';
}

It’s quite simple:

function Start() {
    var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
    cube.name = 'brown_cube';
    // color is controlled like this
    cube.renderer.material.color = Color.brown; // for example
    // There are lots more colours to choose
}

Hope this helps!

Answers (like almost all answers) are out of date and not working in recent versions of Unity.
Here’s a working version:

GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.name = "brown_cube";
Color brown = new Color(139f/255f, 69f/255f, 19f/255f, 1f);
// color is controlled like this
cube.GetComponent<Renderer>().material.color = brown;