Javascript or statement not working

var strExt  = GetAttributeFromItemTable(itemTable, "Ext", "FileType");

I made a warning for strExt and it resolved. if (strExt! = 'wav') {// this works}

if (strExt!='wav' || strExt!='mp3')
{
// this does not work.
}
+5
source share
6 answers

Your logic is wrong:

if your variable strExtwas equal 'wav', it would not be equal 'mp3'and versa-visa.

Please explain your desired results more clearly.

I think you are trying to say something like (neither 'wav', nor 'mp3'):

if ( !( strExt == 'wav' || strExt == 'mp3' ) )

which is logically equivalent (not 'wav', not 'mp3'):

if ( strExt != 'wav' && strExt != 'mp3' ) )
+11
source

, True strExt ( "wav", "mp3" ). ?

, OR ( " " wav ", " mp3 ")?

+1

|| : - , , .

, true || false , falls || true .

: " strExt wav mp3, ". , , .

, && . logical and : " true, " - , false.

, :

if (strExt!='wav' && strExt!='mp3')
+1

, , , :

if ((strExt !== "wav") && strExt !== "mp3") {

}

OR .

0

if, strExt 'wav', 'mp3', &&.

if (strExt!='wav' || strExt!='mp3')

strExt='wav' = > strExt!='wav'= false; strExt!='mp3'= true = > false true = true if strExt='mp3'.

0

, :

if ((strExt!='wav') || (strExt!='mp3'))
 {
     // this does not work.
 }
0

All Articles