Skip to content

Commit 569be37

Browse files
added new code here
1 parent f3eb221 commit 569be37

File tree

5 files changed

+62
-0
lines changed

5 files changed

+62
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// problem-3
2+
function willSuccess(marks) {
3+
if (!Array.isArray(marks)) {
4+
return "Invalid";
5+
}
6+
let passSubject = 0;
7+
let failSubject = 0;
8+
9+
for (let mark of marks) {
10+
if (typeof mark !== 'number') {
11+
return "Invalid";
12+
}
13+
else if (mark >= 50) {
14+
passSubject++;
15+
}
16+
else {
17+
failSubject++;
18+
}
19+
}
20+
return passSubject > failSubject;
21+
}
22+
const array = 90;
23+
const result = willSuccess(array);
24+
console.log(result);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Problem-4
2+
function validProposal(person1, person2) {
3+
if (typeof person1 !== 'object' || typeof person2 !== 'object') {
4+
return "Invalid";
5+
}
6+
let person1Age = person1.age;
7+
let person2Age = person2.age;
8+
let ageDifference = Math.abs(person1Age - person2Age);
9+
if (person1.gender !== person2.gender && ageDifference <= 7) {
10+
return true;
11+
}
12+
else {
13+
return false;
14+
}
15+
}
16+
const person1 = { name: "toya", gender: "female", age: 24 };
17+
const person2 = { name: "bjoy", gender: "male", age: 32 };
18+
const result = validProposal(person1, person2);
19+
console.log(result);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Problem-5
2+
function calculateSleepTime(times) {
3+
let sum = 0;
4+
for (let time of times) {
5+
sum = sum + time;
6+
if (typeof time !== 'number') {
7+
return "Invalid";
8+
}
9+
}
10+
let hours = Math.floor(sum / 3600);
11+
let minutes = Math.floor((sum % 3600) / 60);
12+
let seconds = sum % 60;
13+
return { hour: hours, minute: minutes, second: seconds };
14+
}
15+
const array = [1000, 499, 519, 300];
16+
const result = calculateSleepTime(array);
17+
console.log(result);

F. Function/special-problem/valid-phone-number.js renamed to F. Function/special-problem/valid-phone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Problem-2
12
function validContact(contact) {
23
if (contact.length === 11 && contact.startsWith("01") && !contact.includes(" ")) {
34
return true;

F. Function/special-problem/vat-calc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Problem-1
12
function calculateVAT(price) {
23
if (typeof price !== 'number' || price < 0) {
34
return "Invalid";

0 commit comments

Comments
 (0)