javascript
function add(a , b) { //define the method/function with parameters 'name' and age. return a +b; }
var x = add(5,3); //call the method by passing parameters (in this case we pass numbers) and assign it to variable 'x'.javascript
console.log( x ); //print the result on your webpage/console using `document` object, this will print '8' to browser Console
This is a very simple function. In real world applications you would likely have more complex functions with parameters and return statements, but this should give an idea of how to create basic JavaScript methods/functions!
Login to Continue, We will bring you back to this content 0