Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a4ac66

Browse files
Complete All Problem.
0 parents commit 2a4ac66

File tree

7 files changed

+234
-0
lines changed

7 files changed

+234
-0
lines changed

‎B10-A-04 .docx

510 KB
Binary file not shown.

‎Submit.js

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
function calculateTax(income, expenses) {
2+
if (income >= 0 && income >= expenses && expenses >= 0) return (income - expenses) * 0.2;
3+
else return "Invalid Input";
4+
}
5+
6+
7+
8+
function sendNotification(email) {
9+
if (typeof email === 'string' && email.includes('@') && email[0] !== '@' && email[email.length - 1] !== '@') {
10+
const n = email.indexOf('@');
11+
const userName = email.slice(0, n);
12+
const domainName = email.slice(n + 1);
13+
14+
return `${userName} sent you an email from ${domainName}`;
15+
16+
} else return "Invalid Email";
17+
}
18+
19+
20+
21+
function checkDigitsInName(name) {
22+
if (typeof name === 'string') {
23+
const number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
24+
const nameArr = name.split('');
25+
let bulName = false;
26+
27+
for (const num of number) {
28+
if (nameArr.includes(num)) {
29+
bulName = true;
30+
break;
31+
}
32+
} return bulName;
33+
} else return "Invalid Input";
34+
}
35+
36+
37+
38+
function calculateFinalScore(obj) {
39+
if (typeof obj === 'object' &&
40+
!Array.isArray(obj) &&
41+
typeof obj.name === 'string' &&
42+
typeof obj.testScore === 'number' &&
43+
obj.testScore <= 50 &&
44+
typeof obj.schoolGrade === 'number' &&
45+
obj.schoolGrade <= 30 &&
46+
typeof obj.isFFamily === 'boolean' &&
47+
!isNaN(obj.schoolGrade) &&
48+
!isNaN(obj.schoolGrade)
49+
) {
50+
const score = obj.isFFamily ? obj.testScore + obj.schoolGrade + 20 : obj.testScore + obj.schoolGrade;
51+
return score >= 80 ? true : false;
52+
} else return 'Invalid Input';
53+
}
54+
55+
56+
57+
function waitingTime(waitingTimes, serialNumber) {
58+
if (Array.isArray(waitingTimes) &&
59+
typeof serialNumber === 'number' &&
60+
!isNaN(serialNumber) &&
61+
serialNumber > waitingTime.length
62+
) {
63+
const avgTime = waitingTimes.reduce((a, b) => a + b) / waitingTimes.length;
64+
const remindPerson = serialNumber - waitingTimes.length - 1;
65+
return remindPerson * Math.round(avgTime);
66+
67+
} else return 'Invalid Input ';
68+
}
69+
70+
71+
72+
73+
74+
// !###################################################################################
75+
76+
77+
78+
79+
80+
console.log(calculateTax(10000, 3000));
81+
console.log(calculateTax(34000, 1753));
82+
console.log(calculateTax(5000, 1500));
83+
console.log(calculateTax(7000, 7000));
84+
console.log(calculateTax(-5000, 2000));
85+
console.log(calculateTax(6000, -1500));
86+
87+
88+
// ##############################
89+
90+
91+
console.log(sendNotification('zihad@gmail.com'));
92+
console.log(sendNotification('farhan34@yahoo.com'));
93+
console.log(sendNotification('nadim.naem5@outlook.com'));
94+
console.log(sendNotification('fahim234.hotmail.com'));
95+
console.log(sendNotification('sadia8icloud.com'));
96+
97+
98+
// ##############################
99+
100+
101+
console.log(checkDigitsInName("Raj123"))
102+
console.log(checkDigitsInName("Suman"))
103+
console.log(checkDigitsInName("Name2024"))
104+
console.log(checkDigitsInName("!@#"))
105+
console.log(checkDigitsInName(["Raj"]));
106+
107+
108+
// ##############################
109+
110+
111+
console.log(calculateFinalScore({ name: "Rajib", testScore: 45, schoolGrade: 25, isFFamily: true }));
112+
console.log(calculateFinalScore({ name: "Rajib", testScore: 45, schoolGrade: 25, isFFamily: false }));
113+
console.log(calculateFinalScore("hello"));
114+
console.log(calculateFinalScore({ name: "Rajib", testScore: 15, schoolGrade: 25, isFFamily: true }));
115+
116+
117+
// ##############################
118+
119+
120+
console.log(waitingTime([3, 5, 7, 11, 6], 10))
121+
console.log(waitingTime([13, 2], 6))
122+
console.log(waitingTime([13, 2, 6, 7, 10], 6))
123+
console.log(waitingTime([6], 4))
124+
console.log(waitingTime(7, 10))
125+
console.log(waitingTime("[6,2]", 9))
126+
console.log(waitingTime([7, 8, 3, 4, 5], "9"))

‎problem-1.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
function calculateTax(income, expenses) {
4+
if (income >= 0 && income >= expenses && expenses >= 0) return (income - expenses) * 0.2;
5+
else return "Invalid Input";
6+
}
7+
8+
9+
10+
console.log(calculateTax(10000, 3000));
11+
console.log(calculateTax(34000, 1753));
12+
console.log(calculateTax(5000, 1500));
13+
console.log(calculateTax(7000, 7000));
14+
console.log(calculateTax(-5000, 2000));
15+
console.log(calculateTax(6000, -1500));

‎problem-2.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
function sendNotification(email) {
4+
if (typeof email === 'string' && email.includes('@') && email[0] !== '@' && email[email.length - 1] !== '@') {
5+
const n = email.indexOf('@');
6+
const userName = email.slice(0, n);
7+
const domainName = email.slice(n + 1);
8+
9+
return `${userName} sent you an email from ${domainName}`;
10+
11+
} else return "Invalid Email";
12+
}
13+
14+
15+
16+
console.log(sendNotification('zihad@gmail.com'));
17+
console.log(sendNotification('farhan34@yahoo.com'));
18+
console.log(sendNotification('nadim.naem5@outlook.com'));
19+
console.log(sendNotification('fahim234.hotmail.com'));
20+
console.log(sendNotification('sadia8icloud.com'));

‎problem-3.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
3+
function checkDigitsInName(name) {
4+
if (typeof name === 'string') {
5+
const number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
6+
const nameArr = name.split('');
7+
let bulName = false;
8+
9+
for (const num of number) {
10+
if (nameArr.includes(num)) {
11+
bulName = true;
12+
break;
13+
}
14+
} return bulName;
15+
} else return "Invalid Input";
16+
}
17+
18+
19+
20+
console.log(checkDigitsInName("Raj123"))
21+
console.log(checkDigitsInName("Suman"))
22+
console.log(checkDigitsInName("Name2024"))
23+
console.log(checkDigitsInName("!@#"))
24+
console.log(checkDigitsInName(["Raj"]));

‎problem-4.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
function calculateFinalScore(obj) {
4+
if (typeof obj === 'object' &&
5+
!Array.isArray(obj) &&
6+
typeof obj.name === 'string' &&
7+
typeof obj.testScore === 'number' &&
8+
obj.testScore <= 50 &&
9+
typeof obj.schoolGrade === 'number' &&
10+
obj.schoolGrade <= 30 &&
11+
typeof obj.isFFamily === 'boolean' &&
12+
!isNaN(obj.schoolGrade) &&
13+
!isNaN(obj.schoolGrade)
14+
) {
15+
const score = obj.isFFamily ? obj.testScore + obj.schoolGrade + 20 : obj.testScore + obj.schoolGrade;
16+
return score >= 80 ? true : false;
17+
} else return 'Invalid Input';
18+
}
19+
20+
21+
22+
console.log(calculateFinalScore({ name: "Rajib", testScore: 45, schoolGrade: 25, isFFamily: true }));
23+
console.log(calculateFinalScore({ name: "Rajib", testScore: 45, schoolGrade: 25, isFFamily: false }));
24+
console.log(calculateFinalScore("hello"));
25+
console.log(calculateFinalScore({ name: "Rajib", testScore: 15, schoolGrade: 25, isFFamily: true }));

‎problem-5.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
3+
function waitingTime(waitingTimes, serialNumber) {
4+
if (Array.isArray(waitingTimes) &&
5+
typeof serialNumber === 'number' &&
6+
!isNaN(serialNumber) &&
7+
serialNumber > waitingTime.length
8+
) {
9+
const avgTime = waitingTimes.reduce((a, b) => a + b) / waitingTimes.length;
10+
const remindPerson = serialNumber - waitingTimes.length - 1;
11+
return remindPerson * Math.round(avgTime);
12+
13+
} else return 'Invalid Input ';
14+
}
15+
16+
17+
18+
console.log(waitingTime([3, 5, 7, 11, 6], 10))
19+
console.log(waitingTime([13, 2], 6))
20+
console.log(waitingTime([13, 2, 6, 7, 10], 6))
21+
console.log(waitingTime([6], 4))
22+
console.log(waitingTime(7, 10))
23+
console.log(waitingTime("[6,2]", 9))
24+
console.log(waitingTime([7, 8, 3, 4, 5], "9"))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /