-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionAndMethods.js
More file actions
49 lines (48 loc) · 1.1 KB
/
Copy pathfunctionAndMethods.js
File metadata and controls
49 lines (48 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Block of code that perform a specific task, can be invoked any time
// e.g. console.log() to print data
// () to call the function
// How to write a function
// 2 steps
// 1. definition of function
/**
* function functionName(){
* // do some work
* }
*/
welcom();
function myFunction(){
console.log("Welcome to workshop");
}
// 2. function call/ function invoke
myFunction();
let sum=40;
let updatedValue=welcom(sum);
console.log(updatedValue);
// //functions reduce redundancy
// // function input is parameter(function definition)/argument (function call)
// // Nan not a number
// function sum( a, b){
// // local variable block scope
// //console.log(a+b);
// let s= a+b;
// return s;
// // return only one value
// }
// sum(154,560);
// let val= sum(3,66);
// console.log(`sum is ${val}`);
// /** Arrow funciton
// * compact for
// *
// */
const val= (sum) =>{
console.log(sum);
sum+=3;
console.log("Hello, Welcome to this workshop");
return sum;
}
const arrowSum= (a,b)=>{
console.log(a,b);
}
// // console.log(arrowSum(2,4));
// map, reduce, arrow, foreach loop