Click to See Complete Forum and Search --> : If statements..


Alistair
03-25-2006, 08:30 AM
I have 3x "valid=true" and "valid=false" in 3 seperate if statements

How do I make an if statement that works only when all of the 3 return "valid=true?"

I`ve tried the following:

if (valid)
if (valid==true)
if (valid===true)

Thank you

Alistair
03-25-2006, 08:50 AM
...And I`ve just tried if (valid=true) for arguments sake

gph
03-25-2006, 09:08 AM
I think you need to change the 3 if conditions to 1

if(a==b && b==c && c==d)valid=true

Alistair
03-25-2006, 09:10 AM
Nest the ifs?

What would your code be doing as I need to understand what I write.

gph
03-25-2006, 09:14 AM
"&&" means "and" so, pseudo code

if a=b and b=c and c=d valid=true

Alistair
03-25-2006, 09:15 AM
I`ve tried it a different way and I think it`s working fully.

I declared valid at the beginning and took them out of all the if statements and left the end as ==.

Hopefully it`ll all work.

Cheers

felgall
03-25-2006, 02:45 PM
valid = (a==b && b==c && c==d);