-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.js
More file actions
103 lines (83 loc) · 2.55 KB
/
basic.js
File metadata and controls
103 lines (83 loc) · 2.55 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
//console.log("Hello World!");
// function readString(){
// a = "Hello World"
// return a
// }
// console.log(readString());
// function myName(name){
// a = "My name is " + name
// return a
// }
// console.log(myName("Brijesh"));
// function multipleOfNumber(number){
// return number**3
// }
// console.log(multipleOfNumber(5));
// x=multipleOfNumber(10);
// console.log(x);
function celsiusToFahrenheit(celsius){
return (celsius * (9 / 5)) + 32;
}
// temperature = 80
// console.log("Today's temperature is " + temperature + " degree celsius.")
// console.log("Today's temperature is " + celsiusToFahrenheit(temperature) + " degree fahrenheit.")
// function addition(a,b){
// return a + b
// }
// function subtraction(a,b){
// return a - b
// }
// function multiplication(a,b){
// return a * b
// }
// function division(a,b){
// return a / b
// }
// a=20
// b=5
// console.log("Addition of two numbers is " + addition(a,b));
// console.log("Subtraction of two numbers is " + subtraction(a,b));
// console.log("Multiplication of two numbers is " + multiplication(a,b));
// console.log("Division of two numbers is " + division(a,b));
/*
function namesOfPeople(n1,n2,n3,n4){//Header
return n1+" "+n2+" "+n3+" "+n4 //Body
}
console.log(namesOfPeople("Dipambhai", "Jaybhai","Amrishbhai", "Meetbhai"));//calling a function
Suppose you have four parameters but you only have 3 parameters
while calling the function than the last parameter will be defined as undefined.
On other side, if you hace four parameters but you have 5 parameters
while calling the function than it will only take 4 parameter and it will disregard the last parameter.
*/
// function display(){
// temperature = 80
// console.log("Today's temperature is " + temperature + " degree celsius.")
// console.log("Today's temperature is " + celsiusToFahrenheit(temperature) + " degree fahrenheit.")
// }
// display()
//Function inside Function
/* In a child function, you can you a parents's variable*/
// function Calculator(c1, c2){
// function addition(){
// return c1 + c2
// }
// function subtraction(){
// return c1 - c2
// }
// function multiplication(){
// return c1 * c2
// }
// function division(){
// return c1 / c2
// }
// return "Addition: "+addition()+" Subtraction: "+subtraction()+" Multiplication: "+multiplication()+" Division: "+division()
// }
// console.log(Calculator(10,5));
/*function returns another function*/
// function displayTwo(){
// function displayOne(){
// return "Hello"
// }
// return displayOne()
// }
// console.log(displayTwo());