-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path43ArrowFunction.js
50 lines (40 loc) · 1.1 KB
/
43ArrowFunction.js
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
// Arrow Function
// function expresstion
// const singHappyBirthday = function(){
// console.log("happy birthday to you .....");
// }
// singHappyBirthday();
// Arrow function
const singHappyBirthday = () =>{
console.log("happy birthday to you .....");
}
singHappyBirthday();
// Arrow function
const sumThreeNumbers = (number1, number2, number3) =>{
return number1+number2+number3;
}
const ans = sumThreeNumbers(9,7,6);
console.log(ans);
// Arrow function of checking Even function
const isEven = number => {
return number%2===0;
}
console.log(isEven(4));
// Another way of representing single input arrow function
const isEven1 = number1 => number1%2===0;
console.log(isEven1(99));
// Arrow function simple way for single input arrow function
const firstChar = anyString => anyString[0];
console.log(firstChar("singh"));
// Arrow function
const findTarget = (array, target) => {
for(let i=0; i<array.length; i++){
if(array[i]===target){
return i;
}
}
return -1;
}
const myArray = [1,3,8,6,45,90];
const ans3 = findTarget(myArray,45);
console.log(ans3);