is this not a proper use of elseif
i was pretty sure i was doing it just as the cirriculum did before, but all it activates is the daysUntilExpiration <= 10 message


12 Replies

am i supposed to put the else if's into a block?
also its apparent to me i used my escape sequences wrong
i fixed it by swapping the place of the == 0 with the <= 10
I assume if statements take absolute priority, and disregards elseif if it flags as true
first off, fix your indentation
no. it simply follow the first branch in an if/elseif/else that it finds true.
yes, because 5, 1, and 0 are all less than ten (if you passed something in that range), so that condition gets satisfied first and the block exits.
to do what you likely want, reverse the order -- >= 0, 1, 5, 10
i ended up doing that
and you understand why?
i mean yeah, just initially though it was some cureall code for if statements i guess, idk
learning about arrays now and going to implode
idk what you mean by cure for
if
slike...just throw everything in there and not have to worry about it
no, the order matters here. alternatively you could use all
if
s and return
, if you know about return
ing.theyve barely touched on returns so far
will have to wait for that i guess
ok, but just know what i said -- in an
if/elseif/else
chain, the first block with a satisfied condition runs, and none of the others.yep, thanks