SlideShare a Scribd company logo
Intro to Loops
Continued
Diving Deeper into JavaScript Control Statements
(Loops)
- Professor Flo Davis… Mwahaha
Increment/
Decrement Operators
i++ is the same as i = i + 1;
i- - is the same as i = i -1;
Increment Operator
Syntax x++ or ++x
//PostFix
var x = 3;
y = x++ // y =3, x=4
//PreFix
var a = 2;
b = ++a; // a = 3, b =3
Working Example https://developer.mozilla.org/en-US/docs/
Web/JavaScript/Reference/Operators/Arithmetic_Operators
Increment Operator
Example
var x = 5;
x++;
var z = x;
console.log(z) // z = 6;
Working Example http://www.w3schools.com/
js/tryit.asp?filename=tryjs_oper_increment
Decrement Operator
The decrement operator subtracts
Syntax x - - or - - x
// Postfix
var x = 3;
y = x - - ; y = 3, x = 2
// Prefix
var a = 2;
b = - - a; // a = 1, b = 1
Working Example https://developer.mozilla.org/en-US/docs/Web/
JavaScript/Reference/Operators/Arithmetic_Operators
Decrement Operator
Example
var x = 5;
x- - ;
var z = x; // z = 4
Working Example http://
www.w3schools.com/js/tryit.asp?
filename=tryjs_oper_decrement
The For Loop
for(initialize; test; increment/
decrement) { // Code Block//}
Example Standard For Loop
for(var i = 0; i<10; i++)
{console.log(i);} // This will print the
numbers from 1 through 10.
We use i, because that is short for index
For Loop Example
(Decrement)
for(var i=10; i>5; i- - )
{ console.log(i);}
REMEMBER: i++ or i - - is the same
as i+=1, or i -=1, code what ever
works for you best.
Looping Through An
Array with For Loop
var Professor = [‘Florence’, ‘Davis’];
for(var i =0; i<Professor.length;i++)
{console.log(Professor[i]);}
// Let’s refactor code and make it cleaner
var Professor = [‘Florence’, ‘Davis’];
var length = Professor.length;
for(var i = 0; i<length;i++)
{console.log(Professor[i]);}
Oh…It’s Been Awhile
While Loops
While Loops
while(condition) {// statement}
Example var i = 0;
while(i<10){ console.log(i + ‘….. this will go on until we hit
10’);
i += 1; // same as i++ throwing you for a loop making sure
your paying attention haha :) , remember they can be used
interchangeably whatever you prefer.
If you need further explanations don’t forget our good
friends at Mozilla: https://developer.mozilla.org/en-US/
docs/Web/JavaScript/Reference/Statements/while
While Loops II
var n = 0;
while(n < 3) { console.log(“Looping,”);
n++;}
// Will print looping 3 times
Looping…
looping…
Looping…
–Johnny Appleseed
“Happy Coding.”

More Related Content

What's hot

Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
bsdeol28
 
Looping
LoopingLooping
Java Programmin: Selections
Java Programmin: SelectionsJava Programmin: Selections
Java Programmin: Selections
Karwan Mustafa Kareem
 
C++ loop
C++ loop C++ loop
C++ loop
Khelan Ameen
 
Loops in c
Loops in cLoops in c
Nested loops
Nested loopsNested loops
Nested loops
Neeru Mittal
 
Loop c++
Loop c++Loop c++
Loop c++
Mood Mood
 
C++ control loops
C++ control loopsC++ control loops
C++ control loops
pratikborsadiya
 
Looping statement
Looping statementLooping statement
Looping statement
ilakkiya
 
Loop control in c++
Loop control in c++Loop control in c++
Loop control in c++
Debre Tabor University
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
deekshagopaliya
 
Iteration Statement in C++
Iteration Statement in C++Iteration Statement in C++
Iteration Statement in C++
Jaypee Institute of Information Technology
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
Jd Mercado
 
Control statements
Control statementsControl statements
Control statements
Kanwalpreet Kaur
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
Mahantesh Devoor
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
CHANDAN KUMAR
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
Online
 
Looping statements
Looping statementsLooping statements
Looping statements
Chukka Nikhil Chakravarthy
 

What's hot (20)

Presentation on nesting of loops
Presentation on nesting of loopsPresentation on nesting of loops
Presentation on nesting of loops
 
Looping
LoopingLooping
Looping
 
Java Programmin: Selections
Java Programmin: SelectionsJava Programmin: Selections
Java Programmin: Selections
 
C++ loop
C++ loop C++ loop
C++ loop
 
Loops in c
Loops in cLoops in c
Loops in c
 
Nested loops
Nested loopsNested loops
Nested loops
 
Loop c++
Loop c++Loop c++
Loop c++
 
C++ control loops
C++ control loopsC++ control loops
C++ control loops
 
Looping statement
Looping statementLooping statement
Looping statement
 
Loop control in c++
Loop control in c++Loop control in c++
Loop control in c++
 
Looping in c++
Looping in c++Looping in c++
Looping in c++
 
Iteration Statement in C++
Iteration Statement in C++Iteration Statement in C++
Iteration Statement in C++
 
Do...while loop structure
Do...while loop structureDo...while loop structure
Do...while loop structure
 
Control statements
Control statementsControl statements
Control statements
 
Loops in C Programming Language
Loops in C Programming LanguageLoops in C Programming Language
Loops in C Programming Language
 
Loops in c programming
Loops in c programmingLoops in c programming
Loops in c programming
 
Loops c++
Loops c++Loops c++
Loops c++
 
Loops in c++ programming language
Loops in c++ programming language Loops in c++ programming language
Loops in c++ programming language
 
Control structures repetition
Control structures   repetitionControl structures   repetition
Control structures repetition
 
Looping statements
Looping statementsLooping statements
Looping statements
 

Viewers also liked

JavaScript Conditional Statements
JavaScript Conditional StatementsJavaScript Conditional Statements
JavaScript Conditional Statements
Marlon Jamera
 
Writing MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScriptWriting MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScript
Roland Bouman
 
JavaScript Control Statements I
JavaScript Control Statements IJavaScript Control Statements I
JavaScript Control Statements I
Reem Alattas
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
Brian Moschel
 
Event loops in java script 01 - stack
Event loops in java script 01 - stackEvent loops in java script 01 - stack
Event loops in java script 01 - stack
Vishnu Padmanabhan
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
nobel mujuji
 
Lecture 3 Conditionals, expressions and Variables
Lecture 3   Conditionals, expressions and VariablesLecture 3   Conditionals, expressions and Variables
Lecture 3 Conditionals, expressions and Variables
Syed Afaq Shah MACS CP
 
The Loops
The LoopsThe Loops
The Loops
Krishma Parekh
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
Jin Castor
 
Javascript Function
Javascript FunctionJavascript Function
Javascript Function
xxbeta
 

Viewers also liked (10)

JavaScript Conditional Statements
JavaScript Conditional StatementsJavaScript Conditional Statements
JavaScript Conditional Statements
 
Writing MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScriptWriting MySQL User-defined Functions in JavaScript
Writing MySQL User-defined Functions in JavaScript
 
JavaScript Control Statements I
JavaScript Control Statements IJavaScript Control Statements I
JavaScript Control Statements I
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Event loops in java script 01 - stack
Event loops in java script 01 - stackEvent loops in java script 01 - stack
Event loops in java script 01 - stack
 
Javascript conditional statements
Javascript conditional statementsJavascript conditional statements
Javascript conditional statements
 
Lecture 3 Conditionals, expressions and Variables
Lecture 3   Conditionals, expressions and VariablesLecture 3   Conditionals, expressions and Variables
Lecture 3 Conditionals, expressions and Variables
 
The Loops
The LoopsThe Loops
The Loops
 
Looping statements in Java
Looping statements in JavaLooping statements in Java
Looping statements in Java
 
Javascript Function
Javascript FunctionJavascript Function
Javascript Function
 

Similar to Loops in JavaScript

M C6java6
M C6java6M C6java6
M C6java6
mbruggen
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
Intelligo Technologies
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
Intelligo Technologies
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
Gagan Deep
 
JavaFXScript
JavaFXScriptJavaFXScript
JavaFXScript
webuploader
 
Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
Hassen Poreya
 
Java tut1
Java tut1Java tut1
Java tut1
Ajmal Khan
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
Vijay A Raj
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
Abdul Aziz
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
guest5c8bd1
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
Ashen Disanayaka
 
Eo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5eEo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5e
Gina Bullock
 
Eo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5eEo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5e
Gina Bullock
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
Akash Pandey
 
Python - Lecture 2
Python - Lecture 2Python - Lecture 2
Python - Lecture 2
Ravi Kiran Khareedi
 
control statements
control statementscontrol statements
control statements
Azeem Sultan
 
Python programing
Python programingPython programing
Python programing
hamzagame
 
Elixir/OTP for PHP developers
Elixir/OTP for PHP developersElixir/OTP for PHP developers
Elixir/OTP for PHP developers
Ignacio Martín
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in ruby
Koen Handekyn
 
Looping
LoopingLooping

Similar to Loops in JavaScript (20)

M C6java6
M C6java6M C6java6
M C6java6
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
C lecture 3 control statements slideshare
C lecture 3 control statements slideshareC lecture 3 control statements slideshare
C lecture 3 control statements slideshare
 
JavaFXScript
JavaFXScriptJavaFXScript
JavaFXScript
 
Web app development_php_05
Web app development_php_05Web app development_php_05
Web app development_php_05
 
Java tut1
Java tut1Java tut1
Java tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Php + my sql
Php + my sqlPhp + my sql
Php + my sql
 
Eo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5eEo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5e
 
Eo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5eEo gaddis java_chapter_05_5e
Eo gaddis java_chapter_05_5e
 
Java Tutorial
Java Tutorial Java Tutorial
Java Tutorial
 
Python - Lecture 2
Python - Lecture 2Python - Lecture 2
Python - Lecture 2
 
control statements
control statementscontrol statements
control statements
 
Python programing
Python programingPython programing
Python programing
 
Elixir/OTP for PHP developers
Elixir/OTP for PHP developersElixir/OTP for PHP developers
Elixir/OTP for PHP developers
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in ruby
 
Looping
LoopingLooping
Looping
 

Recently uploaded

22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
edwin408357
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
Yasser Mahgoub
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 

Recently uploaded (20)

22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Engineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdfEngineering Standards Wiring methods.pdf
Engineering Standards Wiring methods.pdf
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 08 Doors and Windows.pdf
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 

Loops in JavaScript

  • 1. Intro to Loops Continued Diving Deeper into JavaScript Control Statements (Loops) - Professor Flo Davis… Mwahaha
  • 2. Increment/ Decrement Operators i++ is the same as i = i + 1; i- - is the same as i = i -1;
  • 3. Increment Operator Syntax x++ or ++x //PostFix var x = 3; y = x++ // y =3, x=4 //PreFix var a = 2; b = ++a; // a = 3, b =3 Working Example https://developer.mozilla.org/en-US/docs/ Web/JavaScript/Reference/Operators/Arithmetic_Operators
  • 4. Increment Operator Example var x = 5; x++; var z = x; console.log(z) // z = 6; Working Example http://www.w3schools.com/ js/tryit.asp?filename=tryjs_oper_increment
  • 5. Decrement Operator The decrement operator subtracts Syntax x - - or - - x // Postfix var x = 3; y = x - - ; y = 3, x = 2 // Prefix var a = 2; b = - - a; // a = 1, b = 1 Working Example https://developer.mozilla.org/en-US/docs/Web/ JavaScript/Reference/Operators/Arithmetic_Operators
  • 6. Decrement Operator Example var x = 5; x- - ; var z = x; // z = 4 Working Example http:// www.w3schools.com/js/tryit.asp? filename=tryjs_oper_decrement
  • 7. The For Loop for(initialize; test; increment/ decrement) { // Code Block//} Example Standard For Loop for(var i = 0; i<10; i++) {console.log(i);} // This will print the numbers from 1 through 10. We use i, because that is short for index
  • 8. For Loop Example (Decrement) for(var i=10; i>5; i- - ) { console.log(i);} REMEMBER: i++ or i - - is the same as i+=1, or i -=1, code what ever works for you best.
  • 9. Looping Through An Array with For Loop var Professor = [‘Florence’, ‘Davis’]; for(var i =0; i<Professor.length;i++) {console.log(Professor[i]);} // Let’s refactor code and make it cleaner var Professor = [‘Florence’, ‘Davis’]; var length = Professor.length; for(var i = 0; i<length;i++) {console.log(Professor[i]);}
  • 11. While Loops while(condition) {// statement} Example var i = 0; while(i<10){ console.log(i + ‘….. this will go on until we hit 10’); i += 1; // same as i++ throwing you for a loop making sure your paying attention haha :) , remember they can be used interchangeably whatever you prefer. If you need further explanations don’t forget our good friends at Mozilla: https://developer.mozilla.org/en-US/ docs/Web/JavaScript/Reference/Statements/while
  • 12. While Loops II var n = 0; while(n < 3) { console.log(“Looping,”); n++;} // Will print looping 3 times Looping… looping… Looping…