SlideShare a Scribd company logo
Performing calculations using java script
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

More Related Content

What's hot (20)

c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
AAKASH KUMAR
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
rricky98
 
Templates
TemplatesTemplates
Templates
Nilesh Dalvi
 
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
faala
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
Muhammad khan
 
Map, Reduce and Filter in Swift
Map, Reduce and Filter in SwiftMap, Reduce and Filter in Swift
Map, Reduce and Filter in Swift
Aleksandras Smirnovas
 
Lec2+lec3
Lec2+lec3Lec2+lec3
Lec2+lec3
Umer Warraich
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
amar kakde
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
eShikshak
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
dishti7
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
Saugat Gautam
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
Jordan Delacruz
 
Overview of c (2)
Overview of c (2)Overview of c (2)
Overview of c (2)
Aayush Patel
 
Java 2
Java 2Java 2
Java 2
Preethi Nambiar
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java script
Abhinav Somani
 
Variables
VariablesVariables
Variables
Jesus Obenita Jr.
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Komal2525
 
C operator and expression
C operator and expressionC operator and expression
C operator and expression
LavanyaManokaran
 
operators in c++
operators in c++operators in c++
operators in c++
Kartik Fulara
 
Thesis PPT
Thesis PPTThesis PPT
Thesis PPT
Drew Ferkin
 
c++ programming Unit 4 operators
c++ programming Unit 4 operatorsc++ programming Unit 4 operators
c++ programming Unit 4 operators
AAKASH KUMAR
 
C OPERATOR
C OPERATORC OPERATOR
C OPERATOR
rricky98
 
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
faala
 
2. operators in c
2. operators in c2. operators in c
2. operators in c
amar kakde
 
Lecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operatorsLecture 8 increment_and_decrement_operators
Lecture 8 increment_and_decrement_operators
eShikshak
 
Basic c operators
Basic c operatorsBasic c operators
Basic c operators
dishti7
 
Functional Programming in Swift
Functional Programming in SwiftFunctional Programming in Swift
Functional Programming in Swift
Saugat Gautam
 
Operators in java script
Operators   in  java scriptOperators   in  java script
Operators in java script
Abhinav Somani
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
Komal2525
 

Viewers also liked (6)

Presentation
PresentationPresentation
Presentation
ch samaram
 
Shore
ShoreShore
Shore
ch samaram
 
Java scripts
Java scriptsJava scripts
Java scripts
Capgemini India
 
Spintronics
SpintronicsSpintronics
Spintronics
ch samaram
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
ch samaram
 
Groovy scripts with Groovy
Groovy scripts with GroovyGroovy scripts with Groovy
Groovy scripts with Groovy
Andrés Viedma Peláez
 
Ad

Similar to Performing calculations using java script (20)

JavaScript: Operators and Expressions
JavaScript: Operators and ExpressionsJavaScript: Operators and Expressions
JavaScript: Operators and Expressions
LearnNowOnline
 
Java script questions
Java script questionsJava script questions
Java script questions
Srikanth
 
Unit2wt
Unit2wtUnit2wt
Unit2wt
vamsi krishna
 
Unit2wt
Unit2wtUnit2wt
Unit2wt
vamsitricks
 
JavaScript Operators
JavaScript OperatorsJavaScript Operators
JavaScript Operators
Charles Russell
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operators
Mohit Rana
 
datatypes-and-operators in wed development.pptx
datatypes-and-operators in wed development.pptxdatatypes-and-operators in wed development.pptx
datatypes-and-operators in wed development.pptx
FahimMousa
 
Java Script Language Tutorial
Java Script Language TutorialJava Script Language Tutorial
Java Script Language Tutorial
vikram singh
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
Google maps
Google mapsGoogle maps
Google maps
Muhammed M Bassem
 
CCv1.0 ppt02 - operators
CCv1.0 ppt02 - operatorsCCv1.0 ppt02 - operators
CCv1.0 ppt02 - operators
appAcademy
 
Arithmetic operators
Arithmetic operatorsArithmetic operators
Arithmetic operators
Sumayyiah .
 
2 1 expressions
2 1  expressions2 1  expressions
2 1 expressions
Ken Kretsch
 
Weird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaionWeird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaion
SrishtyMangutte
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
L3. Operators in JS, CSE 202, BN11.pdf JavaScript
L3. Operators in JS, CSE 202, BN11.pdf JavaScriptL3. Operators in JS, CSE 202, BN11.pdf JavaScript
L3. Operators in JS, CSE 202, BN11.pdf JavaScript
SauravBarua11
 
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
M Sajid R
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
Javascript - Arithmetic in Javascript
Javascript - Arithmetic in JavascriptJavascript - Arithmetic in Javascript
Javascript - Arithmetic in Javascript
Samuel Santos
 
JavaScript: Operators and Expressions
JavaScript: Operators and ExpressionsJavaScript: Operators and Expressions
JavaScript: Operators and Expressions
LearnNowOnline
 
Java script questions
Java script questionsJava script questions
Java script questions
Srikanth
 
Javascript operators
Javascript operatorsJavascript operators
Javascript operators
Mohit Rana
 
datatypes-and-operators in wed development.pptx
datatypes-and-operators in wed development.pptxdatatypes-and-operators in wed development.pptx
datatypes-and-operators in wed development.pptx
FahimMousa
 
Java Script Language Tutorial
Java Script Language TutorialJava Script Language Tutorial
Java Script Language Tutorial
vikram singh
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 
CCv1.0 ppt02 - operators
CCv1.0 ppt02 - operatorsCCv1.0 ppt02 - operators
CCv1.0 ppt02 - operators
appAcademy
 
Arithmetic operators
Arithmetic operatorsArithmetic operators
Arithmetic operators
Sumayyiah .
 
Weird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaionWeird Javascript Weekends first session presentaion
Weird Javascript Weekends first session presentaion
SrishtyMangutte
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
Julie Iskander
 
L3. Operators in JS, CSE 202, BN11.pdf JavaScript
L3. Operators in JS, CSE 202, BN11.pdf JavaScriptL3. Operators in JS, CSE 202, BN11.pdf JavaScript
L3. Operators in JS, CSE 202, BN11.pdf JavaScript
SauravBarua11
 
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
M Sajid R
 
Operators in python
Operators in pythonOperators in python
Operators in python
eShikshak
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
Javascript - Arithmetic in Javascript
Javascript - Arithmetic in JavascriptJavascript - Arithmetic in Javascript
Javascript - Arithmetic in Javascript
Samuel Santos
 
Ad

More from 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
Jesus Obenita Jr.
 
Organization and management 2 Management Function
Organization and management 2 Management FunctionOrganization and management 2 Management Function
Organization and management 2 Management Function
Jesus Obenita Jr.
 
Organization and management 1
Organization and management 1Organization and management 1
Organization and management 1
Jesus Obenita Jr.
 
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
Jesus Obenita Jr.
 
Ms excel 2013 formatting worksheets
Ms excel 2013 formatting worksheetsMs excel 2013 formatting worksheets
Ms excel 2013 formatting worksheets
Jesus Obenita Jr.
 
Ms excel 2013 data management
Ms excel 2013 data managementMs excel 2013 data management
Ms excel 2013 data management
Jesus Obenita Jr.
 
Microsoft Excel introduction
Microsoft Excel introductionMicrosoft Excel introduction
Microsoft Excel introduction
Jesus Obenita Jr.
 
Word 2013 working with pictures
Word 2013 working with picturesWord 2013 working with pictures
Word 2013 working with pictures
Jesus Obenita Jr.
 
Word 2013 Formatting Page
Word 2013 Formatting PageWord 2013 Formatting Page
Word 2013 Formatting Page
Jesus Obenita Jr.
 
Word 2013 8
Word 2013 8Word 2013 8
Word 2013 8
Jesus Obenita Jr.
 
Ms word 2013 7
Ms word 2013 7Ms word 2013 7
Ms word 2013 7
Jesus Obenita Jr.
 
Ms word 2013 6
Ms word 2013 6Ms word 2013 6
Ms word 2013 6
Jesus Obenita Jr.
 
Ms word 2013 4
Ms word 2013 4Ms word 2013 4
Ms word 2013 4
Jesus Obenita Jr.
 
Ms word 2013 2
Ms word 2013 2Ms word 2013 2
Ms word 2013 2
Jesus Obenita Jr.
 
Ms word 2013
Ms word 2013Ms word 2013
Ms word 2013
Jesus Obenita Jr.
 
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
Jesus Obenita Jr.
 
Word processor
Word processorWord processor
Word processor
Jesus Obenita Jr.
 
Session 2 test construction.mt's
Session 2   test construction.mt'sSession 2   test construction.mt's
Session 2 test construction.mt's
Jesus Obenita Jr.
 
Cooking ingredients
Cooking ingredientsCooking ingredients
Cooking ingredients
Jesus Obenita Jr.
 
Color theory
Color theoryColor theory
Color theory
Jesus Obenita Jr.
 

Recently uploaded (20)

The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo SlidesOverview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
BUSINESS QUIZ PRELIMS | QUIZ CLUB OF PSGCAS | 9 SEPTEMBER 2024
Quiz Club of PSG College of Arts & Science
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdfThe Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
LDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation SamplerLDMMIA GRAD Student Check-in Orientation Sampler
LDMMIA GRAD Student Check-in Orientation Sampler
LDM & Mia eStudios
 
Black and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdfBlack and White Illustrative Group Project Presentation.pdf (1).pdf
Black and White Illustrative Group Project Presentation.pdf (1).pdf
AnnasofiaUrsini
 
june 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptxjune 10 2025 ppt for madden on art science is over.pptx
june 10 2025 ppt for madden on art science is over.pptx
roger malina
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo SlidesOverview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdfABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
Allomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdfAllomorps and word formation.pptx - Google Slides.pdf
Allomorps and word formation.pptx - Google Slides.pdf
Abha Pandey
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptxSPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
How to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 EmployeeHow to Manage & Create a New Department in Odoo 18 Employee
How to Manage & Create a New Department in Odoo 18 Employee
Celine George
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKANMATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_HyderabadWebcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Webcrawler_Mule_AIChain_MuleSoft_Meetup_Hyderabad
Veera Pallapu
 
Introduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdfIntroduction to Generative AI and Copilot.pdf
Introduction to Generative AI and Copilot.pdf
TechSoup
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptxAnalysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Battle of Bookworms 2025 - U25 Literature Quiz by Pragya
Pragya - UEM Kolkata Quiz Club
 

Performing calculations using java script

  • 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