darbok Posted May 15, 2015 Share Posted May 15, 2015 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 More sharing options...
Don E Posted May 15, 2015 Share Posted May 15, 2015 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 More sharing options...
darbok Posted May 15, 2015 Author Share Posted May 15, 2015 thats what i was doing wrong, I wasn't accounting for "and" even though verbally i was saying greater than 1 and less than 4, i wasn't writing the 'and' in... thanks. Link to comment Share on other sites More sharing options...
Hadien Posted May 17, 2015 Share Posted May 17, 2015 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now