-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile44.js
82 lines (59 loc) · 1.36 KB
/
file44.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"use stict";
// function
// funstion declarition
// funstion expression
// function declarition
function sumOfTwoNumber(a,b){
let sum = a + b ;
return sum;
}
sum1 = sumOfTwoNumber(2,12);
console.log(sum1);
// odd or even
// input : 1 Number
// output : true : false
// function declarition
// function isEven(number){
// another short trick
// return number % 2 === 0;
// if (number % 2 === 0){
// return true;
// }
// return false;
// }
// console.log(isEven(21));
// funstion expression
const isEven = function (number){
// another short trick
return number % 2 === 0;
// if (number % 2 === 0){
// return true;
// }
// return false;
}
console.log(isEven(21));
// function
// input : String
// output : first CharacterData
// function firstString(string) {
// return string[0];
// }
// console.log(firstString("afdad"));
// function declarition
// input : Array, target(number)
// output : index of tagert if target present in Array
// function declarition
// function checkTarget(array,target)
// function expression
const checkTarget = function(array,target)
{
for(let i =0 ; i<array.length;i++){
if (array[i] === target) {
return i;
}
}
return -1;
}
const myarray = [1,2,3,4,5,6,7,8,9,10];
const j = checkTarget(myarray,11);
console.log(j);