You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ramesh Fadatare edited this page Aug 11, 2020
·
1 revision
In this source code example, you will learn how to add two numbers and display their sum in JavaScript.
We use the addition operator + to add two or more numbers.
JavaScript Add Two Numbers
functionadd(num1,num2){// add two numbersreturnnum1+num2;}letnum1=10;letnum2=20;letsum=add(num1,num2);// display the sumconsole.log('The sum of '+num1+' and '+num2+' is: '+sum);