1
Good afternoon, friends I’m having a problem here in javascript. I have an array, but with each Dice it is adding a double quote, and I want to remove them from there. My code is like this:
dados = new Array();
$.get(url, function(response){
for(i in response.content) {
horario = parseInt(response.content[i].Horario);
tempo = parseInt(response.content[i].Tempo);
dados[i]= "["+ horario +", "+ tempo + "]";
dados[i] = dados[i].replace(' " ', ' ');
}
console.log(dados);
});
And my return is being so
["[0, 54]", "[0, 65]", "[10, 60]"]
And it had to be so:
[[0, 54], [0, 65], [10, 60]]
Does anyone know if why the replace is not working?
EDIT
I forgot to mention the important part, I will use this array for a Chart and the data model he reads is like this:
data: [ [0, 54], [5, 65], [10, 60] ]
so I already concatenei there in it opens "keys" in each of the indices
Luan the way you are doing this creating a monodimensional array of String, and what you want is a two-dimensional array of Int, for that you will have to assign in
dados[i]
the array with the time,– Guilherme Lautert