-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathj1.html
More file actions
127 lines (82 loc) · 3.09 KB
/
Copy pathj1.html
File metadata and controls
127 lines (82 loc) · 3.09 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!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>
// 1- Declare a variable called "name" and assign it the value "John".
/******* Start Your Code *********/
var name="John";
/******* End Your Code ********* */
// 2- Declare a constant called "PI" and assign it the value 3.14.
/******* Start Your Code *********/
const PI= 3.14;
/******* End Your Code ********* */
// 3- Declare a variable called "age" and assign it your age.
/******* Start Your Code *********/
var age= 25;
/******* End Your Code ********* */
// 4- Declare a variable called "isStudent" and assign it a boolean value.
/******* Start Your Code *********/
var isStudent= true;
/******* End Your Code ********* */
// 5- Create a string variable called "message" and assign it a message of your choice.
/******* Start Your Code *********/
var message=" hi";
/******* End Your Code ********* */
// 6- Use template literals to create a string that includes the variables "name" and "age".
/******* Start Your Code *********/
console.log(`my name is ${name},
my age${age}`)
/******* End Your Code ********* */
// 7- Use the string method "length" to find the length of the string "message".
/******* Start Your Code *********/
let length = message.length;
/******* End Your Code ********* */
// 8- Use the string method "toUpperCase()" to convert the string "message" to uppercase.
/******* Start Your Code *********/
let result = message.toUpperCase();
console.log(result)
/******* End Your Code ********* */
// 9- Use the string method "toLowerCase()" to convert the string "message" to lowercase.
/******* Start Your Code *********/
let result2 = message.toLowerCase();
/******* End Your Code ********* */
// 10- Use the string method "indexOf()" to find the position of the word "JavaScript" in the string "I love learning JavaScript".
/******* Start Your Code *********/
var msg="I love learning JavaScript"
let result3 = msg.indexOf("JavaScript");
console.log(result3)
/******* End Your Code ********* */
// 11- Use the string method "slice()" to extract a portion of the string "message".
/******* Start Your Code *********/
result=msg.slice(0,5)
console.log(result)
/******* End Your Code ********* */
// 12- Declare a variable called "num1" and assign it a number.
/******* Start Your Code *********/
var num1=233
/******* End Your Code ********* */
// 13- Declare a variable called "num2" and assign it another number.
/******* Start Your Code *********/
let num2=123
/******* End Your Code ********* */
// 14- Use the arithmetic operator "+" to add num1 and num2.
/******* Start Your Code *********/
console.log(num1+num2)
/******* End Your Code ********* */
// 15- Use the arithmetic operator "-" to subtract num1 from num2.
/******* Start Your Code *********/
console.log(num2-num1)
// to rverse num integer we can do this without function or loop
num1-=num2
num2+=num1
num1-=num2
console.log(num1,num2)
/******* End Your Code ********* */
</script>
</body>
</html>