Input:
var array = [["make", "BMW"], ["model","X6"], ["year",2020]];
My Output should be like this:
var object = {
make : “BMW”
model : “X6”,
year : 2020
}
Input:
var array = [["make", "BMW"], ["model","X6"], ["year",2020]];
My Output should be like this:
var object = {
make : “BMW”
model : “X6”,
year : 2020
}
const array = [["make", "BMW"], ["model","X6"], ["year",2020]];
let obj={}
for(let item of array){
obj[item[0]]=item[1]
}
console.log(obj)
You can use Object.fromEntries()
const arr = [["make", "BMW"], ["model","X6"], ["year",2020]];
const res = Object.fromEntries(arr);
console.log(res)