diff options
| author | Martin Parsiegla <[email protected]> | 2020-09-07 13:58:11 +0200 |
|---|---|---|
| committer | Martin Parsiegla <[email protected]> | 2020-09-07 13:58:11 +0200 |
| commit | b4c3c745632bbdcc09fc35fc3bdcbfe601e2cf91 (patch) | |
| tree | 1bba13ec9d82434aa24d55dd1722aeaacd4af5d5 | |
| parent | 8820484e159bead9be36d200f181302e2a45636e (diff) | |
| download | faker-b4c3c745632bbdcc09fc35fc3bdcbfe601e2cf91.tar.xz faker-b4c3c745632bbdcc09fc35fc3bdcbfe601e2cf91.zip | |
Use if construct instead of conditional assignment
| -rw-r--r-- | lib/finance.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/finance.js b/lib/finance.js index 2939a659..8eaf0de9 100644 --- a/lib/finance.js +++ b/lib/finance.js @@ -255,8 +255,14 @@ self.litecoinAddress = function () { * @method faker.finance.iban */ self.iban = function (formatted, countryCode) { - var findFormat = function(currentFormat) { return currentFormat.country === countryCode; }; - var ibanFormat = countryCode ? ibanLib.formats.find(findFormat) : faker.random.arrayElement(ibanLib.formats); + var ibanFormat; + if (countryCode) { + var findFormat = function(currentFormat) { return currentFormat.country === countryCode; }; + ibanFormat = ibanLib.formats.find(findFormat); + } else { + ibanFormat = faker.random.arrayElement(ibanLib.formats); + } + if (!ibanFormat) { throw new Error('Country code ' + countryCode + ' not supported.'); } |
