Q:

Multiplying objects in javascript

I'm doing java script tutorial and i encountered weird piece of code which for the guy doing tutorial work but not for me. And i know why, but i can't figure out why it works for him. He tried and multiplied two objects which i know it can't be done.
Can someone explain me why the following code works for him because result of it, gives me NaN which is normal because it is not a number it's object.
        tool.onKeyDown = function(event) {
                var maxPoint = new Point (view.size.width, view.size.height); 
                //Gives screen width {x:600, y:300}
                var randomPoint = new Point.random();
                //Gives random betwen 0-1 {x:.5, y:0.5}
                var point = maxPoint * randomPoint; //multiplying gives him {300,150}
                console.log(point) // NAN
                new Path.Circle(point, 20).fillColor = "orange";
            }

A:

You need a new point with the new values:
Multiplication works only with numbers, not with objects. If you need to multiply points, then you have to implement that as an own method of Point.
tool.onKeyDown = function(event) {
    var maxPoint = new Point (view.size.width, view.size.height); 
    //Gives screen width {x:600, y:300}
    var randomPoint = new Point.random();
    //Gives random betwen 0-1 {x:.5, y:0.5}
    var point = new Point(maxPoint.x * randomPoint.x, maxPoint.y * randomPoint.y); // gives him {x: 300, y: 150}
    console.log(point) // should return correct result
    new Path.Circle(point, 20).fillColor = "orange";
}

Edit
It works in the example with
<script type="text/javascript" src="paper-full.js"></script>

and a script block with type="text/paperscript"
<script type="text/paperscript" canvas="myCanvas">
// code here
</script>

