Skip to content

Commit

Permalink
Changed "typeof x === 'undefined'" to !x
Browse files Browse the repository at this point in the history
This handles all falsy/truthy values instead of only checking for undefined
  • Loading branch information
sebastianbarry committed Oct 17, 2023
1 parent 6ffb926 commit 259778a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions www/js/survey/multilabel/infinite_scroll_filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ import i18next from "i18next";

const unlabeledCheck = (t) => {
return t.INPUTS
.map((inputType, index) => typeof t.userInput[inputType] === 'undefined')
.map((inputType, index) => !t.userInput[inputType])
.reduce((acc, val) => acc || val, false);
}

const invalidCheck = (t) => {
const retVal =
(typeof t.userInput['MODE'] !== 'undefined' && t.userInput['MODE'].value === 'pilot_ebike') &&
(typeof t.userInput['REPLACED_MODE'] === 'undefined' ||
(t.userInput['MODE'] && t.userInput['MODE'].value === 'pilot_ebike') &&
(!t.userInput['REPLACED_MODE'] ||
t.userInput['REPLACED_MODE'].value === 'pilot_ebike' ||
t.userInput['REPLACED_MODE'].value === 'same_mode');
return retVal;
}

const toLabelCheck = (trip) => {
if (typeof trip.expectation !== 'undefined') {
if (trip.expectation) {
console.log(trip.expectation.to_label)
return trip.expectation.to_label && unlabeledCheck(trip);
} else {
Expand Down

0 comments on commit 259778a

Please sign in to comment.