aboutsummaryrefslogtreecommitdiff
path: root/lib/finance.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/finance.js')
-rw-r--r--lib/finance.js10
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.');
}