From 4cb0c76065a2b32dd8dc9df8151c2113c5acc35d Mon Sep 17 00:00:00 2001 From: Peter Morgan Date: Sat, 28 Dec 2019 22:17:51 -0700 Subject: [PATCH] Refactored copyWithProperties() --- routes/api/v2.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/routes/api/v2.js b/routes/api/v2.js index f9128c7..e9a829d 100644 --- a/routes/api/v2.js +++ b/routes/api/v2.js @@ -95,13 +95,11 @@ const fetchAllWithPagination = async (apiPath, page, lst) => { * @param {*} props * @param {*} obj */ -function copyWithProperties(props, obj) -{ - var newO = new Object(); - for(var i =0; i < props.length; i++) - { - newO[props[i]] = obj[props[i]]; - } +const copyWithProperties = (props, obj) => { + let newO = new Object(); + props.forEach(prop => { + newO[prop] = obj[prop]; + }) return newO; }