<!DOCTYPE html>
<html>
<head>
  <title>Defining Methods for an Object-aimtocode</title>
  <script type="text/javascript">
   function addPrice(amount)//Function definition
   {
    this.price=amount;
   }    
   function book(title,author)//constructor
   {
    this.title = title;
    this.author = author;
    this.addPrice = addPrice;
   }
  </script>
</head>
<body>
<script type="text/javascript">
  var myBook = new book("Coding for world","Pvpn");
  myBook.addPrice(400);
  document.write("Book title is : "+myBook.title+"<br>");
  document.write("Book author is : "+myBook.author+"<br>");
  document.write("Book price is : "+myBook.price+"<br>");
</script>
</body>
</html>