Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

No Downloads

Total views

464

On SlideShare

0

From Embeds

0

Number of Embeds

1

Shares

0

Downloads

6

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Performing Mathematical Calculations
- 2. 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:
- 3. Arithmetic OperatorsOperator Description + Addition - Subtraction * Multiplication / Division % Modulus (remainder of a division) ++ Increment -- Decrement
- 4. Web browser result: 10 + y= 22Explanation: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
- 5. <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.
- 6. If you add a numeric value and a text or string value, the result will be a text or stringExamples: Statement Resultz= 10+5; 15z= “3”+ “3”; 33z= 8+ “15”; 815z= “11”+12; 1112
- 7. • <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)
- 8. • <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.
- 9. COMPUQUIZ/EXERCISES1. 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 = 33variable y= 10 + xPut the result in an alert box

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment