-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathifelseque.js
More file actions
133 lines (89 loc) · 2.41 KB
/
ifelseque.js
File metadata and controls
133 lines (89 loc) · 2.41 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
128
129
130
131
132
133
/*1. If-Else (Basic)
Q: Write a program that checks if a number is even or odd.
let num = prompt("enter Number check number are odd or even");
if(num % 2 === 0){
console.log("number are even");
}else{
console.log("number are odd");
}
*/
/*Create a program that compares two numbers and prints which one is larger.
let a = prompt("enter frist number")
let b = prompt("enter second number")
if (a>b) {
console.log("a is greter");
}else{
console.log("b is greter");
}
*/
// Create a traffic light system that suggests actions ("Go", "Slow down", "Stop") based on light color.
// let light = prompt("Enter Light Color")
// if(light === "green"){
// console.log("Go");
// }
// if(light === "red"){
// console.log("Stop");
// }
// if(light === "yellow"){
// console.log("Slow down");
// }
/*Loop (For Loop)
Q: Print numbers from 1 to 10 using a for loop.*/
// let a = 1;
// for(a; a<=10; a++){
// console.log(a);
// }
/*3. String (Length Check)
Q: Check if a string's length is greater than 5.*/
// let a = prompt("enter string");
// if (a.length >= 5){
// console.log("length are more then 5");
// }else{
// console.log("lenght are small then 5");
// }
// 4. Array Method (Push & Pop)
// Q: Add an element to an array and then remove the last element.
// a = ["hemant", "rahul", "jiya"]
// a.push("priya");
// a.pop("hemant")
// console.log(a);
// 5. Loop (While Loop)
// Q: Print numbers from 10 to 1 in reverse using a while loop.
// let a = 11;
// while(a>=1){
// a--;
// console.log(a);
// }
/*7. String (Uppercase Conversion)
Q: Convert a string to uppercase.*/
// let a = "hemant";
// let b= a.toUpperCase()
// console.log(b);
// 8. Array Method (Filter)
// Q: Filter out even numbers from an array.
// let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// let evenNum = numbers.filter(number=> number% 2 === 0);
// console.log(evenNum);
// let year = 2023 ;
// if((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0){
// console.log("year are leap");
// }else{
// console.log("year are not leap");
// }
// for(let i = 1; i <= 10; i++){
// console.log(i);
// }
// let sum = 0;
// for(let i = 1;i <= 20; i++){
// if(i % 2 === 0)
// sum += i;
// }
// console.log(sum);
// for(let i = 1; i<= 20; i++){
// if(i % 2 === 0){
// console.log(i);
// }
// }
function reverseArray(str){
return str.split("").reverse().join()
}