← 输入框|github.com|刷新
Skip to content

Isn't the If-Else loop is useless?? LINK - https://github.com/bethrobson/Head-First-JavaScript-Programming/blob/master/chapter1/code.js #29

Open

Description

@arnavafk12-ship-it

scoops = 5; while (scoops > 0) { document.write("Another scoop!<br>"); if (scoops < 3) { alert("Ice cream is running low!"); } else if (scoops >= 5) { alert("Eat faster, the ice cream is going to melt!"); } scoops = scoops - 1; } document.write("Life without ice cream isn't the same");

Just look at the line 6 to 8 , the condition would never ever be executed because of the condition scoops -1 it will not go up more than 5. 🤔

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions