From 6cd403d7b1fa6d6277c8918195942f3262378392 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Fri, 10 Feb 2017 11:49:09 -0500 Subject: [PATCH 1/2] Update to use reduce instead of for loop --- src/components/Utilities/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 393b8133..6a310e65 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -37,15 +37,16 @@ class Utilities extends Component { && (!billsRes.err)) { const boxBuildingList = billsRes.data.box_building_list; const allAccounts = accountRes.data.utilities.map((account) => { - let urlDownload = ''; - // Loop through and connect a box URL with this account - for (let i = 0; i < boxBuildingList.length; i += 1) { - const boxFile = boxBuildingList[i]; - if (boxFile.tags === account.account_number) { - urlDownload = boxFile.url_download; - break; + const urlDownload = boxBuildingList.reduce((url, boxFile) => { + if (!url) { + if (boxFile.tags === account.account_number) { + return boxFile.url_download; + } } - } + return url; + }, ''); + console.log(urlDownload); + return this.createUtilityComponent({ building_address: address, utility: account.type, -- GitLab From 1fcf71c2520563897915b5376f92f058e0436e66 Mon Sep 17 00:00:00 2001 From: Conrad S Date: Mon, 13 Feb 2017 09:43:08 -0500 Subject: [PATCH 2/2] Remove console.log statement --- src/components/Utilities/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Utilities/index.js b/src/components/Utilities/index.js index 6a310e65..1cfbd244 100644 --- a/src/components/Utilities/index.js +++ b/src/components/Utilities/index.js @@ -45,7 +45,6 @@ class Utilities extends Component { } return url; }, ''); - console.log(urlDownload); return this.createUtilityComponent({ building_address: address, -- GitLab