I want to put an array into an object with two keys (key, val). This is my code.
var arr = ["hello", "44", "thanks", "32"];
console.log(arr);
console.log(arr.length);
var obj = {};
for (var i = 0; i < arr.length; i++) {
obj.key = arr[i];
}
console.log(obj);
this is the result i would like to have.
obj[0] = {key: "hello", val: "44"};
obj[1] = {key: "thanks", val: "32"};
Thanks allot!