How to calculate multiplication and division of two numbers using JavaScript ? Last Updated : 10 Jan, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report We will see the calculation such as multiplication and division using Javascript. An arithmetic operation operates on two numbers and numbers are called operands. Approach: Multiplication of two numbersCreate the HTML form to take input from the user to perform multiplication operations. Add javascript code inside HTML to perform multiplication logic. Document.getElementById(id).value property returns the value of the value attribute of a text field. The multiplication operator (*) multiplies two or more numbers and returns the product of the operands. Syntax:a*bExample: In this example, we will use the multiplication operator to multiply two numbers. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body style="margin: 30px"> <h1 style="color:green">GeeksforGeeks</h1> <h3>Multiplication using Javascript</h3> <form> 1st Number : <input type="text" id="firstNumber" /><br> 2nd Number: <input type="text" id="secondNumber" /><br> <input type="button" onClick="multiplyBy()" Value="Multiply" /><br> </form> <p>The Result is : <br> <span id="result"></span> </p> <script> function multiplyBy() { num1 = document.getElementById( "firstNumber").value; num2 = document.getElementById( "secondNumber").value; document.getElementById( "result").innerHTML = num1 * num2; } </script> </body> </html> Output: Approach: Division of two numbersDivision The division operator (/) divides two or more numbers. the divided operand is known as the “dividend,” while the dividing operand is referred to as the “divisor.” The “quotient” is the value that remains after division. Create the HTML form to take input from the user to perform division operations. Add JavaScript code inside HTML to perform division logic. Document.getElementById(id).value property returns the value of the value attribute of a text field. Syntax:a / bExample: let a = 50; let b = 20; let c = a / b;Example: Below is the implementation of the above approach: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body style="margin: 30px"> <h1 style="color:green">GeeksforGeeks</h1> <h3>Division using Javascript</h3> <form> 1st Number : <input type="text" id="firstNumber" /><br> 2nd Number: <input type="text" id="secondNumber" /><br> <input type="button" onClick="divideBy()" Value="Divide" /> </form> <p>The Result is : <br> <span id="result"></span> </p> <script> function divideBy() { num1 = document.getElementById( "firstNumber").value; num2 = document.getElementById( "secondNumber").value; document.getElementById( "result").innerHTML = num1 / num2; } </script> </body> </html> Output: multiplication and division of two numbers using JavaScript Comment More infoAdvertise with us Next Article Multiplication Quiz Webapp using HTML CSS and JavaScript N naman9071 Follow Improve Article Tags : JavaScript Web Technologies javascript-operators JavaScript-Questions Similar Reads How to calculate greatest common divisor of two or more numbers/arrays in JavaScript ? In this article, we are given two or more numbers/array of numbers and the task is to find the GCD of the given numbers/array elements in JavaScript. Examples: Input : arr[] = {1, 2, 3} Output : 1 Input : arr[] = {2, 4, 6, 8} Output : 2 The GCD of three or more numbers equals the product of the prim 2 min read How to get decimal portion of a number using JavaScript ? Given a float number, The task is to separate the number into integer and decimal parts using JavaScript. For example, a value of 15.6 would be split into two numbers, i.e. 15 and 0.6 Here are a few methods discussed. These are the following methods: Table of Content Javascript String split() Method 3 min read How to create a Number object using JavaScript ? In this article, we will discuss how to create a Number object using JavaScript. A number object is used to represent integers, decimal or float point numbers, and many more. The primitive wrapper object Number is used to represent and handle numbers. examples: 20, 0.25. We generally don't need to w 2 min read How to calculate minutes between two dates in JavaScript ? Given two dates and the task is to get the number of minutes between them using JavaScript. Approach: Initialize both Date object.Subtract the older date from the new date. It will give the number of milliseconds from 1 January 1970.Convert milliseconds to minutes. Example 1: This example uses the c 2 min read Multiplication Quiz Webapp using HTML CSS and JavaScript In this article, we will see how to create a multiplication quiz web app using HTML, CSS, and JavaScript.Description of Web App: In this web app, random questions come one by one based on basic multiplication. If you give a correct answer, then it will increment by +1, and if you give the wrong answ 3 min read How to Teach Multiplication with 2 Digit Numbers Multiplication is an important mathematical concept that is used to solve different types of problems. Teaching multiplication is essential because it improves a student's capacity to manage more difficult computations and problem-solving assignments, particularly when dealing with 2-digit numbers. 8 min read Like