File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,16 @@ greet(name)
1313

1414
function add(a,b){
1515
console.log(a+b)
16+
return a+b
1617
}
17-
add(4,5), add(4,55), add(4,555)
18+
add(4,5), add(4,55), add(4,555)
19+
let x = add(3,43)
20+
console.log(x)
21+
22+
23+
//Function as expression
24+
let y = function (num) { return num*num}
25+
console.log(y(5))
26+
27+
let z = y(3)
28+
console.log(z)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// program to show the change in global variable
2+
let a = "hello";
3+
4+
function greet() {
5+
a = 3;
6+
}
7+
8+
// before the function call
9+
console.log(a);
10+
11+
//after the function call
12+
greet();
13+
console.log(a); // 3
14+
15+
// program showing local scope of a variable
16+
var a1 = "hello";
17+
18+
function greet1() {
19+
let b = "World"
20+
a1 = "hellooo"
21+
console.log(a1 + b);
22+
}
23+
24+
greet1();
25+
//console.log(a1 + b); // error

0 commit comments

Comments
 (0)