Contenido del Curso
Introduction to JavaScript
Introduction to JavaScript
3. Performing Operations in JavaScript
Understanding Assignment OperatorsMathematical Operations in JavaScriptAssignment Operators in JavaScriptIncrement and Decrement OperatorsChallenge: Variable Operations PracticeComparison Operators in JavaScriptLogical Operators ExplainedChallenge: Compare Variables in JavaScriptConcatenating Strings in JavaScriptChallenge: Build Sentences with JavaScript
4. Controlling Program Flow with Conditional Statements
5. Looping Through Data in JavaScript
Increment and Decrement Operators
Increment and Decrement are operations used to increase or decrease a variable's value by 1
.
Increment
The increment operation is performed using the ++
operator:
let a = 0; a++; console.log(a); a++; console.log(a); a++; console.log(a);
Note
The expression
a++
is equivalent toa = a + 1
ora += 1
.
Decrement
The decrement operation is performed using the --
operator:
let a = 5; a--; console.log(a); a--; console.log(a); a--; console.log(a);
Note
The expression
a--
is equivalent toa = a - 1
ora -= 1
.
Increment and decrement operations are frequently used in loops, which we will discuss in more detail later.
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 3. Capítulo 4