title: use ko.computed with if statement to set object observable property
body: <p>Just got started with knockout and javascript. I'm stuck at setting the object monthData's mPrice value.</p>
  
  <pre><code>function monthData(mYear, mMonth, mSS, mMs, mLimit, mPerItem, mStartingPrice) {
      var self = this;
      self.mYear= mYear;
      self.mMonth = mMonth;
      self.mSs = mSS;
      self.mMs = mMs;
      self.mTotal = mSS + mMs;
      self.mLimit = mLimit;
      self.mPerItem = mPerItem;
      self.mStartingPrice = mStartingPrice;
  };
  </code></pre>
  
  <p>This is were it stops working. if I set self.mPrice = 0 i get all the months printed out atleast.</p>
  
  <pre><code> self.mPrice = ko.computed(function() {
      var limit = self.mLimit;
      var perItem = self.mPerItem;
      var startingPrice = self.mStartingPrice;
      var total = self.mTotal;
      if (total &lt;= limit) {
          return startingPrice;
      } else {
      var aboveLimit = total - limit;
      var extra = aboveLimit * perItem;
      return startingPrice + extra;
      }
  });
  
  }
  
  function statViewModel() {
  this.tak = ko.observable(100);
  this.styckpris = ko.observable(10);
  this.grundpris = ko.observable(500);
  var self = this;
  
  // testing with some months
  self.allMonths = ko.observableArray([
      new monthData(2013, 1, 412, 142, this.tak, this.styckpris, this.grundpris),
      new monthData(2013, 1, 412, 142, this.tak, this.styckpris, this.grundpris),
      new monthData(2013, 1, 412, 142, this.tak, this.styckpris, this.grundpris),
      new monthData(2013, 1, 412, 142, this.tak, this.styckpris, this.grundpris),
      new monthData(2013, 1, 412, 142, this.tak, this.styckpris, this.grundpris)       
  ]);    
  }
  </code></pre>
  
  <p>-Edit:
  Just after I posted I found a missing paranteses. Now I get it to print out but it says:</p>
  
  <pre><code>function d(){if(0&lt;arguments.length){if(!d.equalityComparer||!d.equalityComparer(c,arguments[0]))d.H(),c=arguments[0],d.G();return this}b.r.Va(d);return c}NaN
  </code></pre>
  
  <p>Html:</p>
  
  <pre><code>&lt;p&gt;Tak: &lt;input data-bind="value: tak" /&gt;&lt;/p&gt;
  &lt;p&gt;Styckpris: &lt;input data-bind="value: styckpris" /&gt;&lt;/p&gt;
  &lt;p&gt;Grundpris: &lt;input data-bind="value: grundpris" /&gt;&lt;/p&gt;
  
  &lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
      &lt;th&gt;År&lt;/th&gt;&lt;th&gt;Månad&lt;/th&gt;&lt;th&gt;SS&lt;/th&gt;&lt;th&gt;MS&lt;/th&gt;&lt;th&gt;Total&lt;/th&gt;&lt;th&gt;Pris&lt;/th&gt;
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody data-bind="foreach: allMonths"&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;span data-bind="text: mYear"&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span data-bind="text: mMonth"&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span data-bind="text: mSs"&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span data-bind="text: mMs"&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span data-bind="text: mTotal"&gt;&lt;/span&gt;&lt;/td&gt;
          &lt;td&gt;&lt;span data-bind="text: mPrice"&gt;&lt;/span&gt;&lt;/td&gt;        
      &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>