1/16
These flashcards cover key concepts related to sequences, processing, output, and control flow in JavaScript.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Sequence
The order in which instructions are executed in a program.
Processing
Manipulating or computing data, often involving arithmetic or string operations.
Output
How a program communicates results to the user, commonly through console.log(), alert(), or document.write().
Control Flow
Determines the order in which instructions are executed in a program.
if Statement
A conditional statement that executes a block of code only if the condition is true.
if…else Statement
A conditional statement that provides an alternative block of code to execute if the initial condition is false.
if…else if…else Statement
A conditional statement useful for checking multiple conditions.
switch Statement
A control structure that executes code based on discrete values of an expression.
for Loop
A control flow statement that repeatedly executes a block of code a specified number of times.
while Loop
A control flow statement that repeatedly executes a block of code as long as a specified condition is true.
Input
How a program receives data from the user or external sources.
What are the three optional parts of a for
loop's header statement?
Initialization, condition, and increment/decrement.
When is a for
loop typically preferred over a while
loop?
When the number of iterations is known beforehand.
What is a key difference between for
and while
loops regarding their termination condition?
A for
loop's iteration count is often predetermined, while a while
loop continues as long as a condition remains true, making it suitable for situations where the number of iterations is unknown.
What risk is associated with a while
loop if its condition never becomes false?
An infinite loop, which can cause a program to freeze.
What are common ways a program can receive input from a user in a web browser?
Through form fields (e.g., <input>
, <textarea>
), prompt dialogs, or event listeners (e.g., keydown
, click
).
Besides user interaction, what are other sources of input for a program?
Data from files, network requests, databases, or sensors.