- Write a function `add` that uses a closure that performs addition on arguments in two separate function calls. code example
Example 1: How to create a function in javascript
function addfunc(a, b) {
return a + b;
// standard long function
}
addfunc = (a, b) => { return a + b; }
// cleaner faster way creating functions!
Example 2: variable used in a function can be used in another function js
function medium(){
var user1=new collector(one,two);
var user2=new collector(one,two);
login(user1,user2);
}
function login(user1,user2){
var u1=user1.username;
var u12=user1.password;
var u2=user2.username;
var u22=user2.password;
}