title: pass an array of data through a variable in jquery
body: <p>I'm working with an apex graph:<a href="https://i.stack.imgur.com/I2Kfi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I2Kfi.png" alt="The graph in question" /></a></p>
  <p>It needs 2 arrays, 1 being the data of the current year and the other from last year, showing the difference between 2 years (or months).
  I have succeeded into making it work with php, but I need to make it more dynamic so I decided to make it using jquery.</p>
  <pre><code>var sum = &quot;&quot;;
      $.each(data, function(k, v){
        sum += v[&quot;sum&quot;] + ', ';
      })
  </code></pre>
  <p>This piece of code stores all this data:</p>
  <blockquote>
  <p>605.00, 4575.00, 4405.00, 3865.00, 3430.00, 2670.00, 1975.00, 650.00, 1945.00, 2800.00, 1960.00, 1905.00, 1600.00, 2070.00, 750.00, 2415.00, 1330.00, 1470.00, 1295.00, 2190.00, 1525.00, 300.00, 2255.00, 1270.00, 1230.00, 1330.00, 1405.00, 1140.00, 1200.00, 1725.00, 1775.00,</p>
  </blockquote>
  <p>Now I need to grab the variable <code>sum</code> and insert it into the graph. This is my attempt:</p>
  <pre><code>name:&quot;Current Month&quot;,type:&quot;line&quot;,data:[sum]}]
  </code></pre>
  <p>The <code>sum</code> variable seen in that line of code is supposed to send that string of numbers into the graph but for some reason it's not working. Am I supposed to echo it somehow?</p>
  <p>Thanks!</p>