I have two arrays: newParamArr and paramVal.
Example values in the newParamArr array: [ "Name", "Age", "Email" ].
Example values in the paramVal array: [ "Jon", 15, "[email protected]" ].
I need to create a JavaScript object that places all of the items in the array in the same object. For example { [newParamArr[0]]: paramVal[0], [newParamArr[1]]: paramVal[1], ... }.
In this case, the result should be { Name: "Jon", "Age": 15, "Email": "[email protected]" }.
The lengths of the two arrays are always the same, but the length of arrays can increase or decrease. That means newParamArr.length === paramVal.length will always hold.
None of the below posts could help to answer my question:
Javascript Recursion for creating a JSON object
Recursively looping through an object to build a property list
newParamArrandparamValand the wanted result.newParamArr[i]an array with the content["Name", "Age", "Email"]or is the arraynewParamArr = ["Name", "Age", "Email"]?