title: Javascript alert statement with string & int
body: <p>Im a newbie to Javascript and trying to debug a simple js function..I need to get the value of x through the alert statement but it doesn't display correctly..How to concatenate a string and int as in this case..</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script&gt;
              function displaydate()  
              {
                  document.getElementById("test").innerHTML='first line changed';
                  document.getElementById("test1").innerHTML='second line changed';
                  var x = 5;
                  alert("Value of x" + String.valueOf(x));
              }
          &lt;/script&gt;
          &lt;p id="test"&gt;this is the 1st line&lt;/p&gt;
          &lt;p id="test1"&gt;this is the 2nd line&lt;/p&gt;
          &lt;button type="button" onclick="displaydate()"&gt;clickme!&lt;/button&gt;
  
      &lt;body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>New code:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;script&gt;
              function displaydate()  
              {
                  document.getElementById("test").innerHTML='first line changed';
                  document.getElementById("test1").innerHTML='second line changed';
                  var x = 5;
                  alert("Value of x=" + x);
                  var cars=new Array();
                  cars[0]='car';
                  cars[1]='Volvo';
                  alert("Value of arrary 1 var=' + cars[0]);
                  //alert("Value of arrary 2 var='+cars[1]);
              }
          &lt;/script&gt;
          &lt;p id="test"&gt;this is the 1st line&lt;/p&gt;
          &lt;p id="test1"&gt;this is the 2nd line&lt;/p&gt;
          &lt;button type="button" onclick="displaydate()"&gt;clickme!&lt;/button&gt;
  
      &lt;body&gt;
  &lt;/html&gt;
  </code></pre>