title: Multiply strings
body: <p><strong>Problem Set</strong>- Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.</p>
  
  <p>My algorithm seems to work fine for all but one test case of palindrome from 1-9</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Javascript has a parse method but I don't want to use that as the problem is from leetcode or a matter of fact from any such site and the problem sets says that explicitly.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//**Input:**
  var n1 = "123456789"
  var n2 = "987654321"
  
  var multiply = function(str1, str2) {
    var sum = 0, k = 1;
    for( var i = str1.length - 1; i&gt;=0; i--){
        var val1 = parseInt(str1[i], 10) * k;
  
        k *= 10;
        var d = 1;
        for(var j = str2.length - 1; j &gt;=0; j--){
            var val2 = parseInt(str2[j], 10) * d;
            d *= 10;
  
            sum +=  val1 * val2;
  
        }
    }
    return sum.toString();
  };
  
  console.log(multiply(n1,n2))</code></pre>
  </div>
  </div>
  </p>
  
  <p>I cannot understand what's going wrong. Other palindromes work fine though. </p>