[Solved] javascript using or operator to iterate over list of strings [duplicate]


Unfortunately, that’s not how the || operator works. You’d have to write:

fileheader[j] !== 'GENE_NAME' || fileheader[j] !== 'logCPM' // ...etc

The other option is creating an array and using indexOf:

if (['GENE_NAME', 'logCPM', 'logFC', 'FOR', 'PValue'].indexOf(j) < 0) {
}

If you’re only worried about newer browsers, you may also be able to get away with includes instead of indexOf.

solved javascript using or operator to iterate over list of strings [duplicate]