I couldn't resist refactoring the example Rick gave on the if statements lesson

if (Hungry === true){
while(wife != watching){
EatJunkFood();
break;
}
}

forgive my stupid post…

No reason to use a while loop if you’re going to break on the first iteration. I would just write this as:

if (hungry && !wifeWatching) {
    EatJunkFood();
}

Privacy & Terms