Skip to content

Commit c1d963d

Browse files
committed
updated
1 parent cab0686 commit c1d963d

File tree

62 files changed

+1383
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1383
-0
lines changed

101. PasswordValidator.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let password = "hey@123";
2+
let cpassword = "hey@124";
3+
4+
password === cpassword ? console.log("Password Matched. Password validation Successful.") : console.log("Password didn't match. Password validation unsuccessful");

102. Calculator.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function calculator(num1, num2 , operator) {
2+
switch (operator) {
3+
case "+":
4+
return (num1 + num2);
5+
break;
6+
case "-":
7+
return (num1 - num2);
8+
break;
9+
case "*":
10+
return (num1 * num2);
11+
break;
12+
case "/":
13+
return (num1 / num2);
14+
break;
15+
16+
default:
17+
console.log("Invalid operator");
18+
break;
19+
}
20+
}
21+
22+
let num1 = 9;
23+
let num2 = 7;
24+
let operator = "**"
25+
let result = calculator(num1, num2, operator);

103. ColorMixer.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
let color1 = "yellow";
2+
let color2 = "red";
3+
4+
switch (color1) {
5+
case "red":
6+
switch (color2) {
7+
case "blue":
8+
console.log("purple");
9+
break;
10+
11+
case "yellow":
12+
console.log("orange");
13+
break;
14+
15+
default:
16+
console.log("Invalid color combination");
17+
break;
18+
}
19+
break;
20+
21+
case "blue":
22+
switch (color2) {
23+
case "red":
24+
console.log("purple");
25+
break;
26+
27+
case "yellow":
28+
console.log("green");
29+
break;
30+
31+
default:
32+
console.log("Invalid color combination");
33+
break;
34+
}
35+
36+
case "yellow":
37+
switch (color2) {
38+
case "red":
39+
console.log("orange");
40+
break;
41+
42+
case "blue":
43+
console.log("green");
44+
break;
45+
46+
default:
47+
console.log("Invalid color combination");
48+
break;
49+
}
50+
break;
51+
52+
default:
53+
console.log("Invalid color combination");
54+
break;
55+
}

104. HighestMarks.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
let marks = [67, 77, 97, 57, 87];
2+
3+
(((marks[0]) > (marks[1])) && ((marks[0]) > (marks[2])) && ((marks[0]) > (marks[3])) && ((marks[0]) > (marks[4])))
4+
5+
? console.log(marks[0])
6+
7+
: (((marks[1]) > (marks[0])) && ((marks[1]) > (marks[2])) && ((marks[1]) > (marks[3])) && ((marks[1]) > (marks[4])))
8+
9+
? console.log(marks[1])
10+
11+
: (((marks[2]) > (marks[0])) && ((marks[2]) > (marks[1])) && ((marks[2]) > (marks[3])) && ((marks[2]) > (marks[4])))
12+
13+
? console.log(marks[2])
14+
15+
: (((marks[3]) > (marks[0])) && ((marks[3]) > (marks[1])) && ((marks[3]) > (marks[2])) && ((marks[3]) > (marks[4])))
16+
17+
? console.log(marks[3])
18+
19+
: (((marks[4]) > (marks[0])) && ((marks[4]) > (marks[1])) && ((marks[4]) > (marks[2])) && ((marks[4]) > (marks[3])))
20+
21+
? console.log(marks[4])
22+
23+
: console.log("All Students Got Equal Marks");

105. Capitalize.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function toUpperCase(names) {
2+
return (names.charCodeAt(0) >= 97)
3+
? names = String.fromCharCode(names.charCodeAt(0)-32) + names.slice(1)
4+
: names;
5+
}
6+
7+
let names = "subhranil";
8+
names = toUpperCase(names);
9+
console.log(names);

106. VowelCounter.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let names = "Subhranil";
2+
let vowelcount = 0;
3+
4+
for (let i = 0 ; i < names.length; i++) {
5+
let x = names[i].toLowerCase();
6+
if (x == "a" || x == "e" || x == "i" || x == "o" || x == "u") {
7+
vowelcount++;
8+
}
9+
}
10+
11+
console.log(`Vowel Count = ${vowelcount}`);

107. RemoveDuplicates.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
function removeDuplicates(cartWithDuplicates) {
2+
let cartWithoutDuplicates = [];
3+
4+
for (let item of cartWithDuplicates) {
5+
if (!cartWithoutDuplicates.includes(item)) {
6+
cartWithoutDuplicates.push(item);
7+
}
8+
}
9+
10+
return cartWithoutDuplicates;
11+
}
12+
13+
let cartWithDuplicates = [1, 5, 6, 8, 1, 5, 4];
14+
let cartWithoutDuplicates = removeDuplicates(cartWithDuplicates);
15+
console.log(cartWithoutDuplicates);

108. Pattern.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let pattern = "";
2+
3+
for (let i = 1; i <= 6; i++) {
4+
for (let j = 6; j >= i; j--) {
5+
pattern = pattern + "*";
6+
}
7+
pattern = pattern + "\n";
8+
}
9+
10+
console.log(pattern);

109. CheckForDivisibility.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
let arr = [3, 6, 9, 12, 15, 18];
2+
3+
for (let i = 0; i < arr.length; i++) {
4+
if ((arr[i] % 3 == 0) && (arr[i] % 2 != 0)) {
5+
console.log(`${arr[i]} is Divisible by 3 but not by 2`);
6+
}
7+
8+
else continue;
9+
}

110. CorrectBug.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function doubleCart (cart) {
2+
for (let i = 0; i < cart.length; i++) {
3+
cart[i] = cart[i] * 2;
4+
}
5+
return cart;
6+
}
7+
8+
let cart = [1, 2, 3, 4];
9+
let newCart = doubleCart(cart);
10+
console.log(newCart);

111. UnitConverter.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function CelsiusToFahrenheit(celsius) {
2+
let fahrenheit = (celsius * 1.8) + 32;
3+
return fahrenheit
4+
}
5+
6+
let celsius = 39.6;
7+
let fahrenheit = CelsiusToFahrenheit(celsius);
8+
console.log(fahrenheit);

112. CalculateRentalCost.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function costOfRent(numberofdays, typeofcar) {
2+
switch(typeofcar) {
3+
case "economy":
4+
return (4000 * numberofdays);
5+
6+
case "midsize":
7+
return (10000 * numberofdays);
8+
9+
case "luxury":
10+
return (20000 * numberofdays);
11+
12+
default: console.log("Invalid Car Type");
13+
}
14+
}
15+
16+
let numberofdays = 5;
17+
let typeofcar = "midsize";
18+
19+
let rent = costOfRent(numberofdays, typeofcar);
20+
console.log(rent);

113. BillSplitter.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function calculateTotalBill(cost, numerofpeople) {
2+
let totalbill = 0;
3+
4+
for (let item of cost) {
5+
totalbill += item;
6+
}
7+
8+
let ammountperhead = totalbill / numerofpeople;
9+
return {totalbill: totalbill, ammountperhead: ammountperhead};
10+
}
11+
12+
let cost = [55, 122, 89, 76, 58];
13+
let numerofpeople = 4;
14+
15+
let finaldetails = calculateTotalBill(cost, numerofpeople);
16+
console.log(finaldetails);

114. CalculateFinalOrderPrice.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let calculateFinalOrderPrice = (cart) => {
2+
let totalcost = 0;
3+
4+
for(let i = 0; i < cart.length; i++) {
5+
totalcost += (cart[i].unitprice * cart[i].quantity);
6+
}
7+
8+
return totalcost;
9+
}
10+
11+
let potato = {unitprice: 18, quantity: 5};
12+
let tomato = {unitprice: 30, quantity: 1};
13+
let carrot = {unitprice: 40, quantity: 2};
14+
15+
let cart = [potato, tomato, carrot];
16+
let totalcost = calculateFinalOrderPrice(cart);
17+
console.log(totalcost);

115. PercentageOfDiscount.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
let precentageOfDiscount = (product) => {
2+
let discount = 100 - (product.discountedprice / product.orignalprice) * 100;
3+
return discount.toFixed(2);
4+
}
5+
6+
let product1 = {orignalprice: 499, discountedprice: 399};
7+
let discount = precentageOfDiscount(product1);
8+
console.log(`Discount = ${discount}%`);

116. RandomNumber.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let randomNumber = (() => {
2+
console.log(Math.floor(Math.random() * 100));
3+
})();

117. BankingApplication.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
let deposit = (customer, money) => {
2+
console.log("\n");
3+
console.log(`Got a request from ${customer.name} to deposit ${money}Rs`);
4+
customer.balance += money;
5+
console.log(`Money Deposit Successful for ${customer.name}`);
6+
console.log("\n");
7+
}
8+
9+
let withdrawl = (customer, money) => {
10+
console.log("\n");
11+
console.log(`Got a request from ${customer.name} to Withdrawl ${money}Rs`);
12+
if (customer.balance < money) {
13+
console.log("Insufficient Balance");
14+
console.log("\n");
15+
}
16+
else {
17+
customer.balance -= money;
18+
console.log(`Money Withdrawl Successful for ${customer.name}`);
19+
console.log("\n");
20+
}
21+
}
22+
23+
let showBalance = (customer) => {
24+
console.log("\n");
25+
console.log(`${customer.name}'s Bank Balance = ${customer.balance}`);
26+
console.log("\n");
27+
}
28+
29+
let bank = (customer, action, money) => {
30+
switch (action) {
31+
case "deposit":
32+
deposit(customer, money);
33+
break;
34+
35+
case "withdrawl":
36+
withdrawl(customer, money);
37+
break;
38+
39+
case "showBalance":
40+
showBalance(customer);
41+
break;
42+
43+
default:
44+
console.log("Invalid Action");
45+
break;
46+
}
47+
}
48+
49+
let customer1 = {name: "Subhranil", balance: 5000};
50+
bank(customer1, "showBalance");
51+
bank(customer1, "deposit", 4000);
52+
bank(customer1, "showBalance");
53+
bank(customer1, "withdrawl", 3000);
54+
bank(customer1, "showBalance");

118. ChangeTextOnButtonClick.html

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>ChangeTextOnButtonClick</title>
8+
</head>
9+
<body>
10+
<center>
11+
<h1 id="text">The most affordable learning platform</h1>
12+
<button onclick="changeText()">Click Me</button>
13+
</center>
14+
15+
<script>
16+
let changeText = () => {
17+
let x = document.querySelector("#text");
18+
if (x.innerHTML == "The most affordable learning platform") {
19+
x.innerHTML = "PW Skills";
20+
}
21+
else x.innerHTML = "The most affordable learning platform";
22+
}
23+
</script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)