
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Difference Between Two Numbers Using JavaScript Function
Use Math.abs() inside a JavaScript function to get the difference between two numbers in JavaScript.
Example
You can try to run the following code to get the difference of numbers
<html> <head> <script> var num1, num2; num1 = 50; num2 = 35; var difference = function (num1, num2){ return Math.abs(num1 - num2); } document.write("Difference = "+difference(num1,num2)); </script> </head> <body></body> </html>
Advertisements