there are two properties for my bike method.front gear and rear gear.i want another property which will be a new property called gear ratio property which can be obtained by multiplying front and rear gear numbers.the code i have written giving continuous error.how it can be fixed.

<html>
<head>
</head>
<body>
<script>
function write(){
var bicycle={
   price:20000,
   model:"raleigh",
  front_gear:3,
   rear_gear:7,
    gear_ratio:function(){
      ratio:this.front_gear*this.rear_gear
       }
      }
      document.write("this is a "+bicycle.gear_ratio.ratio+" speed bike");
      }
      window.onload=write;
</script>
</body>
</html>

You're combining two different methods of doing this which will fail, need to choose one or the other, try this (Sorry for these not being in code boxes, my work PC doesn't like DaniWeb):

Change line 13 to:
return this.front_gear * this.rear_gear;

Change line 16 to:
document.write("this is a " + bicycle.gear_ratio + " speed bike");

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.