Any direction on this block of code would be appreciated:
Variation One:
var x = 'bar';
function myFunction(){
if (x === ('foo' || 'bar')) {
return 'Match';
} else if (x === 'nofoo'){
return 'No Match';
} else
return 'Blank field';
}
console.log(myFunction());
The console spits out 'Blank field' when I have the string bar for var x.
The console displays 'Match' when I have var x = 'foo'
Variation Two:
If I remove the brackets for the following line:
if (x === 'foo' || 'bar')
Then everything keyed into the var x = '[here]'; becomes a Match.
How does a competent programmer code this so that if x is 'foo' or 'bar' it returns a true statement.