-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFunction.js
More file actions
44 lines (34 loc) · 1017 Bytes
/
Function.js
File metadata and controls
44 lines (34 loc) · 1017 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
// 1) Create a function named greet that takes a name as an argument and prints a greeting message to the console.
{
function greet(name){
console.log(`Good Morning, ${name}`);
}
greet('abhi');
}
// 2) Write a function called square that takes a number as a parameter and returns its square.
{
function square(num){
return num * num;
}
console.log(square(2));
}
// 3) Create a function named isEven that takes an integer as an argument and returns true if it's even and false if it's odd.
{
function isEven(n){
if(n%2==0){
return true;
}else{
return false;
}
}
console.log(isEven(5));
}
// 4) Create a function named countDown that takes a positive integer as a parameter and prints a countdown from that number to 1.
{
function countDown(n){
for (let index = n; index > 0; index--){
console.log(index);
}
}
countDown(10)
}