SlideShare a Scribd company logo
JavaScript – Class 2 prompt() operators Calculations if statement
prompt("Please enter your name", "");
<head> <script language=&quot;JavaScript&quot;> var  myPrompt ; myPrompt  =  prompt(&quot;Please enter your name&quot;, &quot;&quot;); </script> </head> <body> <script language=&quot;JavaScript&quot;> document.write( myPromp t); </script> </body>
Mathematical operators :  +  -  /  *  %  •  Precedence -  *   and  /   are performed first  unless you use parenthesis  Assignment operator:  =   also assigns a value  to a variable  Increment and decrement operators:  ++   --
Comparison operators:  <  <=  >  >=  ==  !=  Logical operators:  &&  ||  !  Commonly used with an “if” statement
<script language=&quot;JavaScript&quot;> alert(1 + 1);  </script>  <script language=&quot;JavaScript&quot;> var firstNumber = 40;  var secondNumber = 20;  alert(firstNumber + secondNumber);  </script>
NaN  – Not a Number  a special value in JavaScript that is returned if you do a calculation with a non-number character IsNaN()  – function  tests if a variable is a number or not  –  returns a Boolean data type returns true if it is a string (because a string is not a number)  returns false if it is a number
<script language=&quot;JavaScript&quot;> alert(isNaN(&quot;teresa&quot;)); </script> See page 6 in handout
if statement  <script language=“JavaScript”>  var variable1 = 123;  var variable2 = 123;  if   ( variable1 == variable2 )   {  alert (&quot;condition true&quot;);  }   </script> no semicolon == means: is the same or is equal or  is true the condition to be evaluated is inside the parenthesis code to be executed if the condition is true see page 7 handout
Using comparison and logical operators <script language=“JavaScript”> var variable1 = 2; var variable2 = 4; var variable3 = 6;   if   ( ( variable1 < variable2 )   ||   ( variable2 < variable3 ) ) { alert (&quot;condition true&quot;); }   </script> See page 8 and 9 in handout
if else statement see page 10 handout Gives you the ability to execute code when the condition evaluates to true  and also when it evaluates to false  if  (condition)  {   code here will execute if condition is true’  }   else   {   code here will execute if condition is false; }
if else statement see page 10 handout <script language=“JavaScript”> var variable1 = 123;  var variable2 = 124;  if  (variable1 == variable2)  {   alert (&quot;true&quot;);  }   else   { alert(&quot;false&quot;); }   </script>
if else if statement see page 11 handout var variable1 = 123; var variable2 = 124; if  (variable1 == variable2)  {  alert(&quot;equal&quot;);  }   else   if (variable1 < variable2) { alert(&quot;less than&quot;); } else   { alert(&quot;none of the above&quot;); }   “ else if “block can be repeated as needed
JavaScript – Class 2 Assignment 2

More Related Content

PPT
CSIS 138 JavaScript Class3
PPT
CSIS 138 Javascript Class1
DOC
Introduction to java script
PPTX
Javascript conditional statements
PPTX
Javascript conditional statements 1
PPTX
Introduction to java script
KEY
Debugging Your Ext JS Code
PPTX
2019-08-23 API contract testing with Dredd
CSIS 138 JavaScript Class3
CSIS 138 Javascript Class1
Introduction to java script
Javascript conditional statements
Javascript conditional statements 1
Introduction to java script
Debugging Your Ext JS Code
2019-08-23 API contract testing with Dredd

What's hot (20)

PPT
If-else and switch-case
DOCX
PPT
Practical Ext JS Debugging
PPTX
Switch case and looping statement
PDF
10. switch case
PPTX
Switch Case in C Programming
PDF
Javascript - Tutorial
PDF
Lecture13 control statementswitch.ppt
PPS
Introduction to php 5
DOCX
Free PHP Book Online | PHP Development in India
PPTX
Javascript - Break statement, type conversion, regular expression
DOCX
Janakiram web
PPTX
Lesson 4 constant
PPT
PHP - Introduction to PHP Error Handling
PDF
Effective PHP. Part 6
DOCX
Static keyword a.z
PPTX
Loops in java script
ODP
Unit Testing
PPT
course slides -- powerpoint
PPTX
Jsp session 10
If-else and switch-case
Practical Ext JS Debugging
Switch case and looping statement
10. switch case
Switch Case in C Programming
Javascript - Tutorial
Lecture13 control statementswitch.ppt
Introduction to php 5
Free PHP Book Online | PHP Development in India
Javascript - Break statement, type conversion, regular expression
Janakiram web
Lesson 4 constant
PHP - Introduction to PHP Error Handling
Effective PHP. Part 6
Static keyword a.z
Loops in java script
Unit Testing
course slides -- powerpoint
Jsp session 10
Ad

Viewers also liked (20)

PDF
웹접근성과 보편적 접근성
PPTX
PPT
Dr. William Allan Kritsonis - Employment Law PPT.
PDF
Integra: Get Your Head in the Cloud (Infographic)
PPTX
Primary celebration (spring 2011)
PPT
Student Attendance PPT. - William Allan Kritsonis, PhD
PPTX
IT104 Week 4 - Module/Function
PPT
Typhoon washi gallery
PPT
Crucible2
PPT
Use Of School Facilities
KEY
Cover Letters, Résumés, and Everything Else
PDF
ANE parallels to Gen 1-11
PPT
Student Drug Testing in Schools - Dr. William Allan Kritsonis
PDF
Practical Puppet: Systems Building Systems
DOC
Lernen2
PPT
精神分裂症知多少?
PPSX
Parents as leaders
PPT
Macambol Messages
PPS
Ukazka Automat
PDF
Waterschapsbond
웹접근성과 보편적 접근성
Dr. William Allan Kritsonis - Employment Law PPT.
Integra: Get Your Head in the Cloud (Infographic)
Primary celebration (spring 2011)
Student Attendance PPT. - William Allan Kritsonis, PhD
IT104 Week 4 - Module/Function
Typhoon washi gallery
Crucible2
Use Of School Facilities
Cover Letters, Résumés, and Everything Else
ANE parallels to Gen 1-11
Student Drug Testing in Schools - Dr. William Allan Kritsonis
Practical Puppet: Systems Building Systems
Lernen2
精神分裂症知多少?
Parents as leaders
Macambol Messages
Ukazka Automat
Waterschapsbond
Ad

Similar to CSIS 138 JavaScript Class2 (20)

PPTX
Introduction to Client-Side Javascript
DOC
Java Script Language Tutorial
PPT
Javascript
PPT
Coding task new
PPT
Introduction to javascript.ppt
PPTX
JavaScript / Web Engineering / Web Development / html + css + js/presentation
PPTX
Unit2wt
PPTX
Unit2wt
PPTX
CSC PPT 13.pptx
PDF
Things to avoid in JavaScript
PPT
The JavaScript Programming Language
PPT
The Java Script Programming Language
PPT
Javascript
PPT
Les origines de Javascript
PPT
Javascript by Yahoo
PPT
Javascript
PDF
javascript-variablesanddatatypes-130218094831-phpapp01.pdf
PPT
Tugas Pw [6]
PPT
Tugas Pw [6] (2)
PPTX
Javascript 101
Introduction to Client-Side Javascript
Java Script Language Tutorial
Javascript
Coding task new
Introduction to javascript.ppt
JavaScript / Web Engineering / Web Development / html + css + js/presentation
Unit2wt
Unit2wt
CSC PPT 13.pptx
Things to avoid in JavaScript
The JavaScript Programming Language
The Java Script Programming Language
Javascript
Les origines de Javascript
Javascript by Yahoo
Javascript
javascript-variablesanddatatypes-130218094831-phpapp01.pdf
Tugas Pw [6]
Tugas Pw [6] (2)
Javascript 101

Recently uploaded (20)

PDF
advance database management system book.pdf
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PPTX
Lesson notes of climatology university.
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Empowerment Technology for Senior High School Guide
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
Final Presentation General Medicine 03-08-2024.pptx
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
advance database management system book.pdf
A systematic review of self-coping strategies used by university students to ...
Digestion and Absorption of Carbohydrates, Proteina and Fats
Lesson notes of climatology university.
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Empowerment Technology for Senior High School Guide
Indian roads congress 037 - 2012 Flexible pavement
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Final Presentation General Medicine 03-08-2024.pptx
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Unit 4 Skeletal System.ppt.pptxopresentatiom
UNIT III MENTAL HEALTH NURSING ASSESSMENT
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
LDMMIA Reiki Yoga Finals Review Spring Summer

CSIS 138 JavaScript Class2

  • 1. JavaScript – Class 2 prompt() operators Calculations if statement
  • 2. prompt(&quot;Please enter your name&quot;, &quot;&quot;);
  • 3. <head> <script language=&quot;JavaScript&quot;> var myPrompt ; myPrompt = prompt(&quot;Please enter your name&quot;, &quot;&quot;); </script> </head> <body> <script language=&quot;JavaScript&quot;> document.write( myPromp t); </script> </body>
  • 4. Mathematical operators : + - / * % • Precedence - * and / are performed first unless you use parenthesis Assignment operator: = also assigns a value to a variable Increment and decrement operators: ++ --
  • 5. Comparison operators: < <= > >= == != Logical operators: && || ! Commonly used with an “if” statement
  • 6. <script language=&quot;JavaScript&quot;> alert(1 + 1); </script> <script language=&quot;JavaScript&quot;> var firstNumber = 40; var secondNumber = 20; alert(firstNumber + secondNumber); </script>
  • 7. NaN – Not a Number a special value in JavaScript that is returned if you do a calculation with a non-number character IsNaN() – function tests if a variable is a number or not – returns a Boolean data type returns true if it is a string (because a string is not a number) returns false if it is a number
  • 9. if statement <script language=“JavaScript”> var variable1 = 123; var variable2 = 123; if ( variable1 == variable2 ) { alert (&quot;condition true&quot;); } </script> no semicolon == means: is the same or is equal or is true the condition to be evaluated is inside the parenthesis code to be executed if the condition is true see page 7 handout
  • 10. Using comparison and logical operators <script language=“JavaScript”> var variable1 = 2; var variable2 = 4; var variable3 = 6; if ( ( variable1 < variable2 ) || ( variable2 < variable3 ) ) { alert (&quot;condition true&quot;); } </script> See page 8 and 9 in handout
  • 11. if else statement see page 10 handout Gives you the ability to execute code when the condition evaluates to true and also when it evaluates to false if (condition) { code here will execute if condition is true’ } else { code here will execute if condition is false; }
  • 12. if else statement see page 10 handout <script language=“JavaScript”> var variable1 = 123; var variable2 = 124; if (variable1 == variable2) { alert (&quot;true&quot;); } else { alert(&quot;false&quot;); } </script>
  • 13. if else if statement see page 11 handout var variable1 = 123; var variable2 = 124; if (variable1 == variable2) { alert(&quot;equal&quot;); } else if (variable1 < variable2) { alert(&quot;less than&quot;); } else { alert(&quot;none of the above&quot;); } “ else if “block can be repeated as needed
  • 14. JavaScript – Class 2 Assignment 2

Editor's Notes

  • #2: The JavaScript Language consists of objects CSIS 138 Instructor Teresa Pelkie Class 2 - Summer 2008