I'm a begginer, so sorry.
I want to get something like, and complete in my code "MDM", "SerialNumber" and "coordonates" with a loop:
Console.log(MDM.SerialNumber.coordonates)
Or something like this would be fine also
Console.log(MDM[SerialNumber].coordonates)
Console.log(MDM[SerialNumber][coordonates])
But I want also this to work (or simililar, I just want it with indexes) :
Console.log(MDM.[0][0])
Then I would like to get an answer like "A2:B3". But when I try this, I have an error, it concerns before when I try to put my data in a loop. This is the error :
Cannot set property 'SerialNumber' of undefined
So now I'm going to explain what I tried : I have multiple columns that I want to have coordonates and data from them : And I have also multiple databases (MDM and dataBase2 (we only study MDM here, but I explain why there is "MDM"))
var MDM = new Object();
var name= ["SerialNumber", "IMEI", "Last_Check-In", "mail", "User_ID"];
Then there is a loop, this loop permit to add what I want in a object. But it's not working at the 3rd line (MDM.this[name[i]] =...), it's where I have the error.
for (var i = 0; i <= name.length-1; i++) {
coordonnatesLetter[i] = col[i] + "2:" + col[i];
colData[i] = ssMDM.getRange(coordonnatesLetter[i]);
MDM.this[name[i]] = { coordonates: coordonnatesLetter[i], data: colData[i]};
}
I tried also something like this for the 3rd line:
MDM[name[i]] = { coordonates: coordonnatesLetter[i], data: colData[i]};
But then I have that about errors on my console.log line: ReferenceError: "coordonates is not defined"
Maybe I should defined coordonates, but I don't know how. I'm a little lost.
Thank you