-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path44.js
More file actions
50 lines (39 loc) · 867 Bytes
/
Copy path44.js
File metadata and controls
50 lines (39 loc) · 867 Bytes
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
function singHappyBirthday()
{
console.log("happy birthday to you ......");
}
function sumThreeNumbers(number1, number2, number3)
{
return number1 + number2 + number3;
}
// isEven
// input : 1 number
// output : true , false
// function isEven(number){
// return number % 2 === 0;
// }
// console.log(isEven(4));
// function
// input : string
// output: firstCharacter
// function firstChar(anyString){
// return anyString[0];
// }
// console.log(firstChar("zbc"));
// function
// input : array, target (number)
// output: index of target if target present in array
function findTarget(array, target)
{
for (let i = 0; i < array.length; i++)
{
if (array[i] === target)
{
return i;
}
}
return -1;
}
const myArray = [1, 3, 8, 90]
const ans = findTarget(myArray, 4);
console.log(ans);