I'm working on a project that allows scheduling of employees. The data is in google sheets, each employee gets workplace designation. There are several possibilities: numbers, Roman numerals, characters, additions,...
The problem is with handling Roman numerals. A whole day is put into array, one item for one employee. My idea is to isolate items containing either 'I' or 'V' (numbers run from I to VII). Next I would like to filter out items that contain some of those letters, but don't fit. Therefore an array with to-be-excluded items is created (these entries are fixed).
Part of the code: (in real, data is fed from sheet. Here is just a sample array)
var monTr = ['u/1', 'I/4', 'G1', 'G23', 'LD', 'E1', 'E2 /3', 'LL', 'VAR', 'III', 'VUV', 'V - 11', 'II', 'PB', 'V', '-', 'IV'];
var toExcl = ['VAR', 'VUV', 'EIT'];
var b = monTr
.map(function (inp, index) { if (inp.indexOf('I') !== -1 || inp.indexOf('V') !== -1) { return index } })
.filter(index => index != null);
Logger.log(b);
var c = monTr
.map(function (inp, index) { if (inp.indexOf('I') !== -1 || inp.indexOf('V') !== -1 && toExcl.forEach(function (item) { inp.indexOf(item) !== -1 })) { return index } })
.filter(index => index != null);
Logger.log(c);
First part works as predicted; b contains IDs of everything with I or V. But the second part doesn't work properly; c doesn't contain IDs 11 ('V - 11') and 14 ('V'). What am I doing wrong?