Javascript problem

I have a simple test scene with two cubes (CubeA and CubeB) and each has a script attached to it (ScriptA and ScriptB).

I want the code in CubeA to be able to access the code in Cube B. I can do the following

//ScriptA

ScriptB.Test();

What I really want to do is more like this

//ScriptA
CubeB.Test();

Is there any way to do this?

Thanks!