Is there a way to continuously add key value pairs to a JSON object within a while loop?
var sName = "string_";
var aKeys = ["1", "2", "3"];
var sKey = "key";
var n = 1;
var aObj = {};
var l = aKeys.length;
for(let i=0; i < l; i++){
while(n < 5)
{
n += 1;
aObj.sKey = sName.concat(n);
}
}
console.log(JSON.stringify(aObj));
expected output:
{"sKey":"string_2", "sKey":"string_3", "sKey":"string_4"}