Created
April 12, 2021 18:54
-
-
Save gaurangrshah/becee5395cb2b4774ca614c013b3a34f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createFormObject(inputsElements) { | |
/** | |
* #SCOPE: takes in an array of inputs and returns a single object with the shape | |
* {[input.name]L input.value} | |
*/ | |
return inputsElements.reduce( | |
(obj, item) => ({ ...obj, [item.name]: item.value.trim() }), // trim whitespace | |
{} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment