An assignment operator assigns a value to its left operand based on the value of its right operand.
Review: The numbers (in an arithmetic operation) are called operands. The operation (to be performed between the two operands) is defined by an operator.
For more complex assignments, the destructuring assignment syntax is a JavaScript expression that makes it possible to extract data from arrays or objects using a syntax that mirrors the construction of array and object literals.
In general, assignments are used within a variable declaration (i.e., with const, let, or var) or as standalone statements).
By chaining or nesting an assignment expression, its result can itself be assigned to another variable. It can be logged, it can be put inside an array literal or function call, and so on. Can result in surprising behavior, so it is discouraged but happens occasionally.
Chaining assignments or nesting assignments in other expressions can result in surprising behavior. For this reason, chaining assignments in the same statement is discouraged.
In particular, putting a variable chain in a const, let, or var statement often does not work. Only the outermost/leftmost variable would get declared; other variables within the assignment chain are not declared by the const/let/var statement.
A comparison operator compares its operands and returns a logical value based on whether the comparison is true.
Comparison/Assignment Operators with Descriptive Tables

Loops offer a quick and easy way to do something repeatedly.
A ‘for’ statement looks like this-
for (initialization; condition; afterthought)
statement
A ‘for’ loop repeats until a specified condition evaluates to false. The JavaScript for loop is similar to the Java and C for loop.
When a for loop executes, the following occurs:
Here, the for statement declares the variable i and initializes it to 0. It checks that i is less than the number of options in the < select > element, performs the succeeding if statement, and increments i by 1 after each pass through the loop.
function countSelected(selectObject) {
let numberSelected = 0;
for (let i = 0; i < selectObject.options.length; i++) {
if (selectObject.options[i].selected) {
numberSelected++;
}
}
return numberSelected;
}
const btn = document.getElementById("btn");
btn.addEventListener("click", () => {
const musicTypes = document.selectForm.musicTypes;
console.log(`You have selected ${countSelected(musicTypes)} option(s).`);
});
In the example below, the function contains a for statement that counts the number of selected options in a scrolling list (a < select > element that allows multiple selections).
<form name="selectForm">
<label for="musicTypes"
>Choose some music types, then click the button below:</label
>
<select id="musicTypes" name="musicTypes" multiple>
<option selected>R&B</option>
<option>Jazz</option>
<option>Blues</option>
<option>New Age</option>
<option>Classical</option>
<option>Opera</option>
</select>
<button id="btn" type="button">How many are selected?</button>
</form>
The do…while statement repeats until a specified condition evaluates to false.
do
statement
while (condition);
In the following example, the do loop iterates at least once and reiterates until i is no longer less than 5.
let i = 0;
do {
i += 1;
console.log(i);
} while (i < 5);
A while statement executes its statements as long as a specified condition evaluates to true.
while (condition)
statement
If the condition becomes false, statement within the loop stops executing and control passes to the statement following the loop.
The condition test occurs before statement in the loop is executed. If the condition returns true, statement is executed and the condition is tested again. If the condition returns false, execution stops, and control is passed to the statement following while.
The following while loop iterates as long as n is less than 3:
let n = 0;
let x = 0;
while (n < 3) {
n++;
x += n;
}
With each iteration, the loop increments n and adds that value to x. Therefore, x and n take on the following values:
How many times will a while loop execute? A while statement executes its statements as long as a specified condition evaluates to true.