Answer the question
In order to leave comments, you need to log in
How to add a key to an object when I don't know what it will be called?
how to add a key to an object when I don't know what it will be called. For example, I will iterate over the values from the array and substitute as a key in the object. Or pass key values through a parameter in a function?
const ass = {};
function insert (key,val){
ass.key = val;
console.log(ass);
}
insert(22,"Ivan")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question