-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay 2
90 lines (84 loc) · 2.02 KB
/
Day 2
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
<!--Q1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>Hello!!</p>
<script src="Q1.js"></script>
</body>
</html>
//q1.js
var name= prompt("What is your name?");
console.log(name);
-->
<!--Q2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Array Methods</h1>
<p>Creating an Array</p>
<script src="Q2.js"></script>
<p>Add an Item at the end of array</p><br>
<p> Length of an Array</p><br>
<p> Push- Add an item at the last</p><br>
<p>Pop- Remove an element from last</p><br>
<p>Shift- Remove an Item from beginning of an array</p><br>
<p>Unshift Add an Item at the beginnign of an array</p><br>
<script src="Q2.js"></script>
<h1>String Methods</h1>
<script>
let a = 'United Nations'
let b = 'India'
if (a < b) { // true
console.log(a + ' is less than ' + b)
} else if (a > b) {
console.log(a + ' is greater than ' + b)
} else {
console.log(a + ' and ' + b + ' are equal.')
}
</script>
</body>
</html>
//q2.js
// Array methods
let fruits =['Apple', 'Banana']
console.log(fruits);
console.log(fruits.length)
let newFruit= fruits.push('Lichi')
console.log(fruits);
let end = fruits.pop("Lichi");
console.log(fruits);
let begin = fruits. shift();
console.log(fruits);
let addBegin = fruits.unshift("Strawberry")
console.log(fruits);
-->
<!--Q3.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let age= prompt("What's your age?")
if(age<21)
result="Cannot Drink";
else
result="Can Drink";
console.log(result);
</script>
</body>
</html>
-->