title: Why do I get an error message that .replace is not a function?
body: <p>I have this function:</p>
  
  <pre><code>function countLitreKgSums(cProductIds){
    var cLitreKgSums = new Array();
    var cWeek = 0;
    for(i=0;i&lt;cProductIds.length;i++){
      var cLitreKgSum = 0;
      $("#plan_table td[class='week']").each(function(){
              cWeek = $(this).html();
              var cLitreKgValue = $("input[name*='plan_table_week" + cWeek + "_prod" + cProductIds[i] + "_']").val();
              if (cLitreKgValue == "") {
                  cLitreKgValue = 0;
              }
              cLitreKgValue = cLitreKgValue.replace(/,/g, '.').replace(/[^\d\.]/g, '').replace(/\s/g, '');
              cLitreKgValue = parseFloat(cLitreKgValue);
              cLitreKgSum += cLitreKgValue;
         });
         cLitreKgSum = Math.round(cLitreKgSum * 100) / 100;
         cLitreKgSums[i] = cLitreKgSum;
    }
    return cLitreKgSums;
    //console.log(cLitreKgSums);
  }
  </code></pre>
  
  <p>I get error message that .replace is not a function but in other functions it works as it should. What is the difference?</p>