Javascript call to class method CalculateCost() does not work correctly. Not returning any information -


I have a class constructor called PortraitOrder (). In this manufacturer, I am making a method called CalculateCost (). For some reason, when I call that method later in my code, nothing returns anything, I'm not sure that the way I call it, if I made it in portrait order , Or the actual calculatec () method has the same problem

  function PortraitOrder (pictures, pictures, copies, shapes, buyers) {this.portrait = portrait; this.copies = copies; This.size = size; this.buyer = buyer; This.calculateCost = calculate; Here is the CalculationCast () method that I have added under PortraitArder ()  
  function under CalculateCost () { this . Size = size; This.copies = copies; Var value = 0; If (size == "wallet") {value = 10; } And if (size == "8x10") {value = 10; } And if (size == "4x6") {value = 10; } And if (size == "11x14") {value = 30; } And {value = 10; } var cost = price * copies; Return cost; }    
  • Finally, this is the call that I make in that method. Portrait is the name of the class created in my code earlier.

      document.write ("Cost of Order:" + portraits.calculateCost ());      

    Your code is likely throwing an exception: Function CalculateCost () {this.size = size; // Size is unknown here for the interpreter. copies = copies; // copies are unknown to interpreter here ...}

    A cleaner and more simple way of doing everything (keep this in mind as well, like Epcarlo said, that you Not using Price :

      Function Portrait Order (images, copies, sizes, buyers) {this.portrait = portrait; this.copies = copies; Size = size; this.buyer = buyer; This.calculateCost = function () {var value = 0; if (size == "wallet") {value = 10;} and if (size == "8x10") {value = 10;} and if (size == "4x6") { Value = 10;} and if (size == "11x14") {value = 30;} and {value = 10;} var cost = size * copies; return cost;}}    

  • Comments

    Popular posts from this blog

    php - PDO bindParam() fatal error -

    logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

    java - Why my included JSP file won't get processed correctly? -