What do we use control structures for in JavaScript?

Control the flow of the program; how the commands execute.

Start our JavaScript program

Store information for later

Teach Karel new commands

1 answer

In JavaScript, we use control structures primarily to control the flow of the program; how the commands execute. Control structures determine the direction in which a program flows, allowing for decision making, looping, and branching. This includes structures like:

  • Conditional statements (if, else if, else, switch) to execute code only when certain conditions are met.
  • Loops (for, while, do...while) to repeat a block of code multiple times based on a condition.
  • Control flow commands (break, continue) to alter the flow of loops.

So the correct answer to your question is the first option: Control the flow of the program; how the commands execute.