title: javascript to calculate the sum of Words
body: <p>inside an html script i have inserted a src java script and created tables with id's which are labelled square1...e.g.<code>&lt;td id="square0"&gt;apple;&lt;/td&gt;.</code>
  i want the javascript to display the sum of the alphabets in the word which are in the html file. like if  a is 1, b is 2, c is 3, d is 4...z is 26 then apple is 50, carrot is 75 and so on. i want the output to be like apple 50, carrot 75, yellow 92</p>
  
  <p>the java script i tried was</p>
  
  <pre><code>var a = 1;
  var b = 2;
  ...
  ...
  var z = 26;
  var addWord = new Array(1);
  addWord[1] = "apple";
  var square01 = 1 + 16 + 16 + 12 + 5;
  
  function() {
      var total = 0;
      for (var i = 0; i &lt; word.length; i++)
      total += alphabet[word[i]];
      document.getElementById(square0).innerHTML;
  }
  }
  </code></pre>
  
  <p>many thanks
  any help will do..</p>