object.fromentries error javasript code example
Example: javascript fromEntries
// JS fromEntries => list of key-values transformation into an object
const keys = ["name", "species", "age", "gender", "color"];
const values = ["Skitty", "cat", 9, "female", "tabby"];
const run = document.getElementById("run");
run.addEventListener("click", function () {
let createObj = [];
keys.forEach((item, index) => {
createObj.push([item, values[index]]);
});
const object = Object.fromEntries(createObj);
console.log(object);
});
// expected output = Object { name: "Skitty", species: "cat", age: 9 etc..}