xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create a function to add two numbers in JavaScript
JavaScript Online Editor
Run Code
More JavaScript Sample Codes
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Function to Add Two Numbers in JavaScript</title> <!--Script tag is added to write JavaScript code inside it--> <script> //function to add two numbers function AddNumber(firstNum, secondNum){ return firstNum + secondNum; } function myFunction() { //FullName() function called var result = AddNumber(12.50, 20); document.getElementById("outPut").innerHTML = "The output of the AddNumber() function is: " + result.toFixed(2); } </script> </head> <body> <h1>How to Create a Function to Add Two Numbers in JavaScript?</h1> <button onclick="myFunction()">Click here to see result</button> <p id="outPut"></p> </body> </html>