How to place a value of a var inside an array item?

Asked

Viewed 57 times

0

I’m touching the Google Charts, but I came across a situation, and I was wondering if you could do something like in the example:

var numero = 45;
var data = google.visualization.arrayToDataTable([
    ['Onyx', '<valor da var numero aqui>]
]);
  • Wouldn’t that be: var data = google.visualization.arrayToDataTable([&#xA; ['Onyx', numero],&#xA;]);?

  • I edited it. I didn’t have that comma at the end but it didn’t work

  • You can report the error you are presenting?

1 answer

0


Guy just pass the variable number inside the vector as Roberto de Campos said, what you have to see is what google.visualization.arrayToDataTable() can receive as parameter. Type pq has a bracket inside the other in the method?

var numero = 45;
var data = ['Onyx', numero];

alert(data);

  • I discovered the bug. Missed giving a parserInt(). But thanks for the feedback, folks <3 solved

Browser other questions tagged

You are not signed in. Login or sign up in order to post.