From ef6a401b5673ec59b76ba3bb0ad65b674f29137c Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Wed, 26 Dec 2018 17:34:02 -0500 Subject: [PATCH] refactor multiple if else into a single condition --- src/app/tabs/run-tab.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/app/tabs/run-tab.js b/src/app/tabs/run-tab.js index 203d1895ea..ad9930b210 100644 --- a/src/app/tabs/run-tab.js +++ b/src/app/tabs/run-tab.js @@ -32,14 +32,8 @@ function runTab (opts, localRegistry) { var index = select.selectedIndex var selectedUnit = select.querySelectorAll('option')[index].dataset.unit var unit = 'ether' // default - if (selectedUnit === 'ether') { - unit = 'ether' - } else if (selectedUnit === 'finney') { - unit = 'finney' - } else if (selectedUnit === 'gwei') { - unit = 'gwei' - } else if (selectedUnit === 'wei') { - unit = 'wei' + if (['ether', 'finney', 'gwei', 'wei'].indexOf(selectedUnit) >= 0) { + unit = selectedUnit } cb(null, executionContext.web3().toWei(number, unit)) } catch (e) {