SlideShare ist ein Scribd-Unternehmen logo
1 von 18
JavaScript – Class 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String Object – comparing strings var  answer = “xyz”; stringName. toLowerCase() ; stringName. toUpperCase() ;
String Object var  answer =  prompt("What breed of dog was Lassie?", "");  if (answer == "collie")  {  document.write("Yes, that is correct!");  }
var  answer =  prompt("What breed of dog was Lassie?", ""); if (answer. toLowerCase()  == "collie")  {  document.write("Yes, Lassie was a collie!");  }  else  {  document.write("No, you are wrong!");  }  comparison
Switch Statement For checking a condition when there are a large number of possibilities  Can be used in place of an if else if What it contains: •  the  test statement  - the expression/condition to test  •  the  case statements  - the possible answers •  the  break statements  – stops checking after a match is •  the  default statement  –executes if none of the possible answers are found
var  theDay=  prompt("What day is the fourth of July?", ""); switch  ( theDay.toLowerCase())  -> the test expression– what we are comparing {   case  “monday”: execute some code;  break;  case  “tuesday” :  execute some code;  break;  default:  -> - the default statement - if nothing matches, this will execute  execute some code;  break;  } See pages 4-6 handout and sample code files Double quotes for a literal/string
the Array Object  – (chapter 2)  •  Similar to a variable except that it can hold more than one item of data at a time  •  Each piece of data stored is referred to as an  element  •  Each element is referenced by a number or an  index  •  The index number is enclosed in brackets –  [ ]  •  Arrays start with the number  0   •  Arrays have a  length property , which is the number of elements in the array  •  Arrays are defined with the JavaScript key word “ new ”  •  The length of the array minus 1 gives the number of the  last index
Declaring an Array var  myArray = new Array()  or   var  myArray = new Array(4) We are creating a “ new ”  instance  of the “ Array() ” object  keyword keyword Array object – upper case “A”
Listing the  elements  in an array var dogs = new Array();  dogs[0] = &quot;Missy&quot; ;  dogs[1] = &quot;Letty&quot; ;  dogs[2] = &quot;Andy&quot; ;  dogs[3] = &quot;Terri&quot; ;  var dogs = new Array(“Missy”, “Letty”, “Andy”, “Terri”); ______________________________________________ Returning the  value  of the array  elements : document.write(&quot;my first dog is &quot; + dogs[0] + &quot;<br>&quot;);  document.write(&quot;my second dog is &quot; + dogs[1] + &quot;<br>&quot;);  see page 8 index position 0
Loops   A loop is a type of JavaScript statement that repeats a block of code over and over again if a condition evaluates to true  Two kinds of loops -– a “ for ” loop and a “ while ” loop  •  Use the “ for ” loop  when you  know , or can determine by a calculation,  the number of times  you want to repeat the code  •  Use the “ while ” loop  when you  do not know how many times  you will need to repeat the block of code
The “for” loop – Commonly used with an array  •  Repeats a block of code for a certain number of times  •  When you know or can determine how many times to repeat the code  •  Involves some kind of  counter  that is  incremented  as long as the condition is true
The “for in” loop –  ONLY  used with an array  •  Repeats a block of code for a certain number of times  •  When you know or can determine how many times to repeat the code  •  Involves some kind of  counter  that is  incremented  as long as the condition is true var elementIndex;  var myArray();  for (elementIndex  in  myArray)  {  document.write(myArray[elementIndex] + “<br>”);  }
for loop - Pages 9 -11
for in loop - Page 12
for in loop - Page 12
while loop  •  Allows you to test a condition and keep on looping as long as the condition is    true;  will stop when the condition is false  •  If the condition is false to begin with, it will never loop  •  Used when you don’t know the number of times you need to loop  •  You must increment the counter in the code to execute or it will loop  indefinitely and the computer will crash ☺  var counter;  counter = prompt(&quot;Enter a number from 1 to 10&quot;, &quot;&quot;);  while (counter <= 10)  {  document.write(&quot;this is count number &quot; + counter + &quot;<br><br>&quot; );  counter++  }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Regex cheatsheet part-1
Regex cheatsheet part-1Regex cheatsheet part-1
Regex cheatsheet part-1
 
Unit 2.5
Unit 2.5Unit 2.5
Unit 2.5
 
Javascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expressionJavascript - Break statement, type conversion, regular expression
Javascript - Break statement, type conversion, regular expression
 
Introduction to php 5
Introduction to php   5Introduction to php   5
Introduction to php 5
 
Loops in java script
Loops in java scriptLoops in java script
Loops in java script
 
Free PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in IndiaFree PHP Book Online | PHP Development in India
Free PHP Book Online | PHP Development in India
 
Javascript - Tutorial
Javascript - TutorialJavascript - Tutorial
Javascript - Tutorial
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
C++ decision making
C++ decision makingC++ decision making
C++ decision making
 
Lesson 4 constant
Lesson 4  constantLesson 4  constant
Lesson 4 constant
 
Janakiram web
Janakiram webJanakiram web
Janakiram web
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Effective PHP. Part 6
Effective PHP. Part 6Effective PHP. Part 6
Effective PHP. Part 6
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
Lesson 3 php numbers
Lesson 3  php numbersLesson 3  php numbers
Lesson 3 php numbers
 
Conditions In C# C-Sharp
Conditions In C# C-SharpConditions In C# C-Sharp
Conditions In C# C-Sharp
 
Bsit1
Bsit1Bsit1
Bsit1
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 

Andere mochten auch

The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...
The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...
The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...William Kritsonis
 
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.Dr. William Allan Kritsonis - Expression & Associational Rights PPT.
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.William Kritsonis
 
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...William Kritsonis
 
ADMN 5053 Special Programs - Dr. W.A. Kritsonis
ADMN 5053 Special Programs - Dr. W.A. KritsonisADMN 5053 Special Programs - Dr. W.A. Kritsonis
ADMN 5053 Special Programs - Dr. W.A. KritsonisWilliam Kritsonis
 
Ch 15 Legalities Affecting Schooling - Dr. William Allan Kritsonis
Ch 15 Legalities Affecting Schooling - Dr. William Allan KritsonisCh 15 Legalities Affecting Schooling - Dr. William Allan Kritsonis
Ch 15 Legalities Affecting Schooling - Dr. William Allan KritsonisWilliam Kritsonis
 
Selem image and_phantoms
Selem image and_phantomsSelem image and_phantoms
Selem image and_phantomsJonathan Swales
 
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...William Kritsonis
 
Samanthas geothermal powerpoint
Samanthas geothermal powerpointSamanthas geothermal powerpoint
Samanthas geothermal powerpointroom112008
 
Graphic Novels Intro # 2
Graphic Novels Intro # 2Graphic Novels Intro # 2
Graphic Novels Intro # 2bradythecamel
 
Witness, Worldview And The Workplace
Witness, Worldview And The WorkplaceWitness, Worldview And The Workplace
Witness, Worldview And The WorkplaceJonathan Swales
 
Presentation
PresentationPresentation
PresentationSallyL
 
How Testing Helped The API 0.6 Migration
How Testing Helped The API 0.6 MigrationHow Testing Helped The API 0.6 Migration
How Testing Helped The API 0.6 MigrationShaun McDonald
 
Viz Transcript2min X
Viz Transcript2min XViz Transcript2min X
Viz Transcript2min Xwatchthefly
 
Cluster coordinators training programme
Cluster coordinators training programmeCluster coordinators training programme
Cluster coordinators training programmeKirti Shivakumar
 

Andere mochten auch (20)

Famous artists
Famous artistsFamous artists
Famous artists
 
tradizii
tradiziitradizii
tradizii
 
The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...
The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...
The Design of an Undergraduate Program in Homeland Security - Jon E. Travis a...
 
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.Dr. William Allan Kritsonis - Expression & Associational Rights PPT.
Dr. William Allan Kritsonis - Expression & Associational Rights PPT.
 
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...
NATIONAL FORUM JOURNALS - A Group of National Refereed Journals on the Leadin...
 
ADMN 5053 Special Programs - Dr. W.A. Kritsonis
ADMN 5053 Special Programs - Dr. W.A. KritsonisADMN 5053 Special Programs - Dr. W.A. Kritsonis
ADMN 5053 Special Programs - Dr. W.A. Kritsonis
 
Ch 15 Legalities Affecting Schooling - Dr. William Allan Kritsonis
Ch 15 Legalities Affecting Schooling - Dr. William Allan KritsonisCh 15 Legalities Affecting Schooling - Dr. William Allan Kritsonis
Ch 15 Legalities Affecting Schooling - Dr. William Allan Kritsonis
 
Selem image and_phantoms
Selem image and_phantomsSelem image and_phantoms
Selem image and_phantoms
 
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...
Dr. Jennifer T. Butcher & Dr. William Allan Kritsonis - Article: A National P...
 
Samanthas geothermal powerpoint
Samanthas geothermal powerpointSamanthas geothermal powerpoint
Samanthas geothermal powerpoint
 
Graphic Novels Intro # 2
Graphic Novels Intro # 2Graphic Novels Intro # 2
Graphic Novels Intro # 2
 
Court Case 5
Court  Case 5Court  Case 5
Court Case 5
 
Witness, Worldview And The Workplace
Witness, Worldview And The WorkplaceWitness, Worldview And The Workplace
Witness, Worldview And The Workplace
 
Presentation
PresentationPresentation
Presentation
 
Court Case 2
Court Case 2Court Case 2
Court Case 2
 
Court Case Employment
Court Case  EmploymentCourt Case  Employment
Court Case Employment
 
How Testing Helped The API 0.6 Migration
How Testing Helped The API 0.6 MigrationHow Testing Helped The API 0.6 Migration
How Testing Helped The API 0.6 Migration
 
Viz Transcript2min X
Viz Transcript2min XViz Transcript2min X
Viz Transcript2min X
 
Ukazka Predvadeni
Ukazka PredvadeniUkazka Predvadeni
Ukazka Predvadeni
 
Cluster coordinators training programme
Cluster coordinators training programmeCluster coordinators training programme
Cluster coordinators training programme
 

Ähnlich wie CSIS 138 JavaScript Class3

Php Loop
Php LoopPhp Loop
Php Looplotlot
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentationAdhoura Academy
 
Php Basics Iterations, looping
Php Basics Iterations, loopingPhp Basics Iterations, looping
Php Basics Iterations, loopingMuthuganesh S
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationM Sajid R
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basicsrobertbenard
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Languagezone
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de JavascriptBernard Loire
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoobirbal
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming LanguageRaghavan Mohan
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascriptMD Sayem Ahmed
 

Ähnlich wie CSIS 138 JavaScript Class3 (20)

Php Loop
Php LoopPhp Loop
Php Loop
 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
 
Introducing Swift v2.1
Introducing Swift v2.1Introducing Swift v2.1
Introducing Swift v2.1
 
CSC PPT 13.pptx
CSC PPT 13.pptxCSC PPT 13.pptx
CSC PPT 13.pptx
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Php Basics Iterations, looping
Php Basics Iterations, loopingPhp Basics Iterations, looping
Php Basics Iterations, looping
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
The Java Script Programming Language
The  Java Script  Programming  LanguageThe  Java Script  Programming  Language
The Java Script Programming Language
 
Les origines de Javascript
Les origines de JavascriptLes origines de Javascript
Les origines de Javascript
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
Javascript
JavascriptJavascript
Javascript
 
Jquery 1
Jquery 1Jquery 1
Jquery 1
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game
 
An introduction to javascript
An introduction to javascriptAn introduction to javascript
An introduction to javascript
 

Kürzlich hochgeladen

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

Kürzlich hochgeladen (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

CSIS 138 JavaScript Class3

  • 1.
  • 2. String Object – comparing strings var answer = “xyz”; stringName. toLowerCase() ; stringName. toUpperCase() ;
  • 3. String Object var answer = prompt(&quot;What breed of dog was Lassie?&quot;, &quot;&quot;); if (answer == &quot;collie&quot;) { document.write(&quot;Yes, that is correct!&quot;); }
  • 4. var answer = prompt(&quot;What breed of dog was Lassie?&quot;, &quot;&quot;); if (answer. toLowerCase() == &quot;collie&quot;) { document.write(&quot;Yes, Lassie was a collie!&quot;); } else { document.write(&quot;No, you are wrong!&quot;); } comparison
  • 5. Switch Statement For checking a condition when there are a large number of possibilities Can be used in place of an if else if What it contains: • the test statement - the expression/condition to test • the case statements - the possible answers • the break statements – stops checking after a match is • the default statement –executes if none of the possible answers are found
  • 6. var theDay= prompt(&quot;What day is the fourth of July?&quot;, &quot;&quot;); switch ( theDay.toLowerCase()) -> the test expression– what we are comparing { case “monday”: execute some code; break; case “tuesday” : execute some code; break; default: -> - the default statement - if nothing matches, this will execute execute some code; break; } See pages 4-6 handout and sample code files Double quotes for a literal/string
  • 7. the Array Object – (chapter 2) • Similar to a variable except that it can hold more than one item of data at a time • Each piece of data stored is referred to as an element • Each element is referenced by a number or an index • The index number is enclosed in brackets – [ ] • Arrays start with the number 0 • Arrays have a length property , which is the number of elements in the array • Arrays are defined with the JavaScript key word “ new ” • The length of the array minus 1 gives the number of the last index
  • 8. Declaring an Array var myArray = new Array() or var myArray = new Array(4) We are creating a “ new ” instance of the “ Array() ” object keyword keyword Array object – upper case “A”
  • 9. Listing the elements in an array var dogs = new Array(); dogs[0] = &quot;Missy&quot; ; dogs[1] = &quot;Letty&quot; ; dogs[2] = &quot;Andy&quot; ; dogs[3] = &quot;Terri&quot; ; var dogs = new Array(“Missy”, “Letty”, “Andy”, “Terri”); ______________________________________________ Returning the value of the array elements : document.write(&quot;my first dog is &quot; + dogs[0] + &quot;<br>&quot;); document.write(&quot;my second dog is &quot; + dogs[1] + &quot;<br>&quot;); see page 8 index position 0
  • 10. Loops A loop is a type of JavaScript statement that repeats a block of code over and over again if a condition evaluates to true Two kinds of loops -– a “ for ” loop and a “ while ” loop • Use the “ for ” loop when you know , or can determine by a calculation, the number of times you want to repeat the code • Use the “ while ” loop when you do not know how many times you will need to repeat the block of code
  • 11. The “for” loop – Commonly used with an array • Repeats a block of code for a certain number of times • When you know or can determine how many times to repeat the code • Involves some kind of counter that is incremented as long as the condition is true
  • 12. The “for in” loop – ONLY used with an array • Repeats a block of code for a certain number of times • When you know or can determine how many times to repeat the code • Involves some kind of counter that is incremented as long as the condition is true var elementIndex; var myArray(); for (elementIndex in myArray) { document.write(myArray[elementIndex] + “<br>”); }
  • 13. for loop - Pages 9 -11
  • 14. for in loop - Page 12
  • 15. for in loop - Page 12
  • 16. while loop • Allows you to test a condition and keep on looping as long as the condition is true; will stop when the condition is false • If the condition is false to begin with, it will never loop • Used when you don’t know the number of times you need to loop • You must increment the counter in the code to execute or it will loop indefinitely and the computer will crash ☺ var counter; counter = prompt(&quot;Enter a number from 1 to 10&quot;, &quot;&quot;); while (counter <= 10) { document.write(&quot;this is count number &quot; + counter + &quot;<br><br>&quot; ); counter++ }
  • 17.
  • 18.

Hinweis der Redaktion

  1. The JavaScript Language consists of objects CSIS 138 Instructor Teresa Pelkie Class 3 - Summer 2008