title: How can i convert a list of objects to an array anf then pass it to my java script
body: <p>I have the following <code>JavaScript</code> that display a chart, currently for testing purposes i am passing Hard-coded array as follow: </p>
  
  <pre><code>@model IEnumerable&lt;Medical.Models.Session&gt;
  
  &lt;script src="../../Scripts/jqplot/jquery.jqplot.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.barRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.categoryAxisRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.pointLabels.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.dateAxisRenderer.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.highlighter.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="../../Scripts/jqplot/jqplot.cursor.min.js" type="text/javascript"&gt;&lt;/script&gt;
  
  
  
  &lt;p&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
  
          line1 = [['23-May-2008', 578.55], ['20-Jun-2008', 566.5], ['25-Jul-2008', 480.88],
          ['22-Aug-2008', 509.84], ['26-Sep-2008', 454.13], ['24-Oct-2008', 379.75],
          ['21-Nov-2008', 303], ['26-Dec-2008', 308.56], ['23-Jan-2009', 299.14],
          ['20-Feb-2009', 346.51], ['20-Mar-2009', 325.99], ['24-Apr-2009', 386.15], ['01-Apr-2012', 786.15]];
          var plot1 = $.jqplot('chart1', [line1], { title: 'Data Point Highlighting',
              axesDefaults: { pad: 1.2 },
              axes: { xaxis: { renderer: $.jqplot.DateAxisRenderer,
                  tickOptions: {
                      formatString: '%d/%b/%Y'
                  }
              },
                  yaxis: { tickOptions: { formatString: '%.2f'} }
              },
              highlighter: { show: true, sizeAdjust: 7.5, tooltipLocation: 'nw'
                  //            , formatString: '&lt;b&gt;%s&lt;/b&gt;'
              }, cursor: { show: true, tooltipOffset: 6 }
          })
  
      });
  
  &lt;/script&gt;
  
  &lt;div id = "chart1"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>But how can i dynamically build the above <code>Line1</code> array to have the Model values, something similar to:</p>
  
  <pre><code>   @foreach (var item in Model) {
        //code goes here,, 
        line1 [1,1] = [item.Date, item.Result]
     }
  </code></pre>