My objetive is create this object:
{
name: string.
birthday: date;
}
by this array:
const dataArray = [
{
"id": "name",
"type": "string";
},
{
"id": "birthday",
"type": "date";
}
]
So, I create a .map of the array, like this:
const inputsValues = {};
dataArray.map(item => {
if(item.type === "date"){
inputsValues[item.id] = new Date(item.value);
return; // this line is the problem
}
inputsValues[item.id] = item.value;
});
Is there a option to make a return in this function without use else
?