diff --git a/utilities/filter.js b/utilities/filter.js index 6bf7d28..c0055f5 100644 --- a/utilities/filter.js +++ b/utilities/filter.js @@ -4,16 +4,22 @@ function isBarcode(toFilter) { } let n = true; function isShelving(toFilter) { + if (!Array.isArray(toFilter)) { + let s = toFilter; + toFilter = Array; + toFilter[0] = s; + } const exp = /^[A-Z][A-Z][A-Z]$/; - toFilter.forEach(element => { - let state = exp.test(element); + for (let i = 0; i < toFilter.length; i++) { + let state = exp.test(toFilter[i]); if (state == false) n = false; - }); + } if (n == false) return false; else return true; } + exports.isBarcode = isBarcode; exports.isShelving = isShelving;