# If-else

## Recommended Posts

Can i right more than one condition in the first "if" area?example:

`	var num;	nam=parseInt(prompt("Choose a number with 3 digits"));	if ((nam<532)&&(nam>928))	{alert("haha")}`

The example is'nt work, why?

num =! nam ?

##### Share on other sites

When is a number going to be both less than 532 and also greater than 928?

##### Share on other sites

`	var num;	num=parseInt(prompt("Choose a number with 3 digits"));	if ((num<532)&&(num>928))	{alert("haha")}`

O.KStill not working!?

##### Share on other sites

It's working fine, see my post above. It's doing just what you're telling it to do.

##### Share on other sites

if i press a number that greater then 928 or smaller then 532, Then the alert will show!

##### Share on other sites

That alert will never show. There is no number that will satisfy this condition:if ((num<532)&&(num>928))There is no number that is smaller than 532 and larger than 928. There are numbers that are either smaller than 532, or larger than 928, but there's not a number that's both.

##### Share on other sites

so can you please right for me the correct JS code?

##### Share on other sites

`if ((num<532)||(num>928))`

thanks