SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Performing Mathematical Calculations
JavaScript Arithmetic Operators
• Arithmetic operators are used to perform
  mathematical calculations on variables and/or
  values. These operators are combined with
  values and/or variables to form a JavaScript
  expression.
• A symbol or other character indicating an
  operation that acts on one or more elements.
• The different JavaScript arithmetic operators
  are listed as follows:
Arithmetic Operators
Operator               Description
   +                     Addition
   -                   Subtraction
   *                  Multiplication
   /                     Division
   %         Modulus (remainder of a division)
  ++                    Increment
   --                   Decrement
Web browser result: 10 + y= 22
Explanation:
var (means variable, optional) This are used to hold values and
   expressions.
let variable y = 12.
Mathematical expression= let variable x= 10 + y (where y is
  equal to 12)
document .write display the result: 10 + y= 22
<script>
msg1= “My Birthday is”
msg2= “December 25, 1972”
msg3= msg1 + msg2;
alert(“ ”+msg3+””)
</script>

Web browser result:
Explanation:
The (+) operator add string variables or text values
  together.
If you add a numeric value and a text or string
      value, the result will be a text or string
Examples:
           Statement              Result

z= 10+5;                            15

z= “3”+ “3”;                        33

z= 8+ “15”;                        815

z= “11”+12;                        1112
• <script>
• z="13"+"13";
• x= 13+13;
• document.write(""+z+"");
• alert(""+x+"");
• </script>
• Result= 1313 (because values on z are
  considered as “text values”)
• Result= 26(because values on x are numeric
  values)
• <script>
• var z= parseFloat("13");
• var x= 13
• var y= z + x;
• document.write(""+y+"");
• </script>
RESULT= z + x = 26

• The parseFloat() function parses a string and returns a floating
  point number.
• This function determines if the first character in the specified
  string is a number. If it is, it parses the string until it reaches the
  end of the number, and returns the number as a number, not as
  a string.
• Note: Only the first number in the string is returned!
• Note: Leading and trailing spaces are allowed.
• Note: If the first character cannot be converted to a number, parseFloat()
  returns NaN.
COMPUQUIZ/EXERCISES
1. A symbol or other character indicating an
  operation that acts on one or more elements.
2. This are used to hold values and expressions.
3. Write the code for the following:
variable x = 33
variable y= 10 + x
Put the result in an alert box

Weitere ähnliche Inhalte

Was ist angesagt?

c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operatorsAAKASH KUMAR
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATORrricky98
 
Presentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersPresentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersfaala
 
2. operators in c
2. operators in c2. operators in c
2. operators in camar kakde
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorseShikshak
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operatorsdishti7
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in SwiftSaugat Gautam
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java scriptAbhinav Somani
 
Insertion sort
Insertion sortInsertion sort
Insertion sortKomal2525
 

Was ist angesagt? (20)

c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
 
Templates
TemplatesTemplates
Templates
 
Presentatioon on type conversion and escape characters
Presentatioon on type conversion and escape charactersPresentatioon on type conversion and escape characters
Presentatioon on type conversion and escape characters
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
 
Lec2+lec3
Lec2+lec3Lec2+lec3
Lec2+lec3
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Overview of c (2)
Overview of c (2)Overview of c (2)
Overview of c (2)
 
Java 2
Java 2Java 2
Java 2
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java script
 
Variables
VariablesVariables
Variables
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
 
operators in c++
operators in c++operators in c++
operators in c++
 
Thesis PPT
Thesis PPTThesis PPT
Thesis PPT
 

Andere mochten auch

Andere mochten auch (6)

Presentation
PresentationPresentation
Presentation
 
Shore
ShoreShore
Shore
 
Java scripts
Java scriptsJava scripts
Java scripts
 
Spintronics
SpintronicsSpintronics
Spintronics
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
Groovy scripts with Groovy
Groovy scripts with GroovyGroovy scripts with Groovy
Groovy scripts with Groovy
 

Ähnlich wie Performing calculations using java script

A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++Neeru Mittal
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
Java script questions
Java script questionsJava script questions
Java script questionsSrikanth
 
The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210Mahmoud Samir Fayed
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetSamuel Lampa
 
Java Script Language Tutorial
Java Script Language TutorialJava Script Language Tutorial
Java Script Language Tutorialvikram singh
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayNatasha Murashev
 

Ähnlich wie Performing calculations using java script (20)

Matlab Basic Tutorial
Matlab Basic TutorialMatlab Basic Tutorial
Matlab Basic Tutorial
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Matlab1
Matlab1Matlab1
Matlab1
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
Java script questions
Java script questionsJava script questions
Java script questions
 
Basics of c++
Basics of c++ Basics of c++
Basics of c++
 
2. operator
2. operator2. operator
2. operator
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
Introduction to DAX Language
Introduction to DAX LanguageIntroduction to DAX Language
Introduction to DAX Language
 
Operators1.pptx
Operators1.pptxOperators1.pptx
Operators1.pptx
 
The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210The Ring programming language version 1.9 book - Part 25 of 210
The Ring programming language version 1.9 book - Part 25 of 210
 
iRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat SheetiRODS Rule Language Cheat Sheet
iRODS Rule Language Cheat Sheet
 
Java Script Language Tutorial
Java Script Language TutorialJava Script Language Tutorial
Java Script Language Tutorial
 
bobok
bobokbobok
bobok
 
Funcitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional WayFuncitonal Swift Conference: The Functional Way
Funcitonal Swift Conference: The Functional Way
 

Mehr von Jesus Obenita Jr.

Mehr von Jesus Obenita Jr. (20)

Organization and management 3 a Evolution of Management Theory
Organization and management 3 a Evolution of Management TheoryOrganization and management 3 a Evolution of Management Theory
Organization and management 3 a Evolution of Management Theory
 
Organization and management 2 Management Function
Organization and management 2 Management FunctionOrganization and management 2 Management Function
Organization and management 2 Management Function
 
Organization and management 1
Organization and management 1Organization and management 1
Organization and management 1
 
Designing web page marquee and img tag
Designing web page  marquee and img tagDesigning web page  marquee and img tag
Designing web page marquee and img tag
 
Ms excel 2013 formatting worksheets
Ms excel 2013 formatting worksheetsMs excel 2013 formatting worksheets
Ms excel 2013 formatting worksheets
 
Ms excel 2013 data management
Ms excel 2013 data managementMs excel 2013 data management
Ms excel 2013 data management
 
Microsoft Excel introduction
Microsoft Excel introductionMicrosoft Excel introduction
Microsoft Excel introduction
 
Word 2013 working with pictures
Word 2013 working with picturesWord 2013 working with pictures
Word 2013 working with pictures
 
Word 2013 Formatting Page
Word 2013 Formatting PageWord 2013 Formatting Page
Word 2013 Formatting Page
 
Word 2013 8
Word 2013 8Word 2013 8
Word 2013 8
 
Ms word 2013 7
Ms word 2013 7Ms word 2013 7
Ms word 2013 7
 
Ms word 2013 6
Ms word 2013 6Ms word 2013 6
Ms word 2013 6
 
Ms word 2013 4
Ms word 2013 4Ms word 2013 4
Ms word 2013 4
 
Ms word 2013 2
Ms word 2013 2Ms word 2013 2
Ms word 2013 2
 
Ms word 2013
Ms word 2013Ms word 2013
Ms word 2013
 
Parts of the ms word 2013 screen and
Parts of the ms word 2013 screen andParts of the ms word 2013 screen and
Parts of the ms word 2013 screen and
 
Word processor
Word processorWord processor
Word processor
 
Session 2 test construction.mt's
Session 2   test construction.mt'sSession 2   test construction.mt's
Session 2 test construction.mt's
 
Cooking ingredients
Cooking ingredientsCooking ingredients
Cooking ingredients
 
Color theory
Color theoryColor theory
Color theory
 

Kürzlich hochgeladen

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 

Kürzlich hochgeladen (20)

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 

Performing calculations using java script

  • 1.
  • 3. JavaScript Arithmetic Operators • Arithmetic operators are used to perform mathematical calculations on variables and/or values. These operators are combined with values and/or variables to form a JavaScript expression. • A symbol or other character indicating an operation that acts on one or more elements. • The different JavaScript arithmetic operators are listed as follows:
  • 4. Arithmetic Operators Operator Description + Addition - Subtraction * Multiplication / Division % Modulus (remainder of a division) ++ Increment -- Decrement
  • 5. Web browser result: 10 + y= 22 Explanation: var (means variable, optional) This are used to hold values and expressions. let variable y = 12. Mathematical expression= let variable x= 10 + y (where y is equal to 12) document .write display the result: 10 + y= 22
  • 6. <script> msg1= “My Birthday is” msg2= “December 25, 1972” msg3= msg1 + msg2; alert(“ ”+msg3+””) </script> Web browser result: Explanation: The (+) operator add string variables or text values together.
  • 7. If you add a numeric value and a text or string value, the result will be a text or string Examples: Statement Result z= 10+5; 15 z= “3”+ “3”; 33 z= 8+ “15”; 815 z= “11”+12; 1112
  • 8. • <script> • z="13"+"13"; • x= 13+13; • document.write(""+z+""); • alert(""+x+""); • </script> • Result= 1313 (because values on z are considered as “text values”) • Result= 26(because values on x are numeric values)
  • 9. • <script> • var z= parseFloat("13"); • var x= 13 • var y= z + x; • document.write(""+y+""); • </script> RESULT= z + x = 26 • The parseFloat() function parses a string and returns a floating point number. • This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string. • Note: Only the first number in the string is returned! • Note: Leading and trailing spaces are allowed. • Note: If the first character cannot be converted to a number, parseFloat() returns NaN.
  • 10. COMPUQUIZ/EXERCISES 1. A symbol or other character indicating an operation that acts on one or more elements. 2. This are used to hold values and expressions. 3. Write the code for the following: variable x = 33 variable y= 10 + x Put the result in an alert box