Jump to content

how would i write?


darbok

Recommended Posts

var numapples = 0;
if (numapples >= 4) {
document.write("I'm apple rich!");
}
else if (numapples > 1 < 4) { <------- this is the part i'm unsure of, how to make sometthing more then one number but less then another.
document.write("I have some apples");
}
else {
document.write("I'm apple poor!");
}
Link to comment
Share on other sites

In the else if condition, you can use && (and) to check if numapples is greater than 1 and less than 4. For example:

else if(numapples > 1 && numapples < 4) 

If numapples is greater than 1 and less than 4, the else if is executed.

Link to comment
Share on other sites

well its inside an elseif so you don't even need to test if the number of apples is less than 4,just if it greater than 1. inside the first "if" expression you test to see if the value is greater than or equal to 4. so if that didn't evaluate to true the value would already automatically be less than 4, checking again in the elseif would just be redundant

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...