How can I convert this object into an Array using GAS?
I got this showing as an object
:
38,44,46
...while and it should be:
["38","44","46"]
I'd like to convert it to an Array, so that I can iterate over it.
I've tried doing so using this, but it's still an object, as I get its type:
let tamanhosEsc = Object.values(values[29]);
This is how values
is created:
const rngList = cadSheet.getRangeList(dataRng).getRanges();
let values = new Array();
for(let i = 0; i < rngList.length; i++) {
let data = rngList[i].getValue();
values.push([data]);
}
I've tried creating it by specifying it as an Array, but still...
Solution 1:
Play with the code above to understand the basic concept:
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
var result = Object.keys(obj).map((key) => [Number(key), obj[key]]);
console.log(result);