Lots of ways to do this
here is one ....
Code:
<script>
Ship = function (){
var speed = 0;
return function (color){
this.faster = function(){speed+=1}
this.color=color;
this.animate = function(){
return speed;}
}
}();
a= new Ship("red");
b= new Ship("blue");
alert(b.color + " ship speed = "+b.animate());
b.faster();
alert(b.color + " ship speed = "+b.animate());
alert(a.color + " ship speed = "+a.animate());
a.faster();
alert(a.color + " ship speed = "+a.animate());
</script>