-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
79 lines (64 loc) · 1.49 KB
/
index.js
File metadata and controls
79 lines (64 loc) · 1.49 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
//area calculation
// var base = prompt("Enter your base: ");
// var height = prompt("Enter your height : ");
// var area = base * height;
// document.write("Area = "+area+"<br>");
//simple calculation
// var num1 = prompt('Enter a first nubmer :');
// var num2 = prompt("Enter a second number :")
// var sum = num1 + num2;
// document.write("the result is : "+sum);
//use to if else
var a = 10;
var b = 20;
var sum = a+b;
if(a == b){
document.write(" a = b : "+ sum);
}else{
document.write("the result is "+sum);
}
for(var x =1 ; x<=10;x++){
document.write("Hello Bangladesh<br>");
}
// use to while loop
var i = 1;
while(i<=100){
document.write("result is :"+i);
i++;
}
// //use ot do while loop
// var x = 11;
// do{
// document.write("pritn the value :"+x);
// }while(i<=20){
// document.write("result now show");
// };
//use to iifes
(function display( x, y ){
var sum = x+y;
document.write("result is :" +sum);
})(1,2);
// function Expreesion
var display2 = function displayMessage(msg){
document.write(msg);
}
display2('i am a programmer');
//use to array
// var nemes = new Array(2);
// names[0] = 'a';
// names[1] = 'a';
// for(var x =0; x<=names.lenght;x++){
// document.write(x);
// }
// use to sort
var numbers = [2,23,24,1,4];
numbers.sort(function(a,b){
return a -b;
});
document.write(numbers);
// use to reverce
var numbers = [2,23,24,1,4];
numbers.sort(function(a,b){
return b - a;
});
document.write(numbers);