Skip to content

Commit ffe92fb

Browse files
added new solved here and added question
1 parent 569be37 commit ffe92fb

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

F. Function/special-problem/admission.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// problem-3
1+
/* problem-3
2+
3+
Shihab is preparing for the university entrance exam. 🎓📖 He has taken various model tests and has scored different marks each time. But he is worried—will he be able to pass the final exam? For Shihab, you write a function called willSuccess(), which takes an Array of Numbers as input and analyzes Shihab's results and gives Shihab a guideline.
4+
A mark of 50 or more in the model test means Pass. And getting below 50 means Fail.
5+
If the number of passed tests is more than the number of failed tests, then he will think that he is ready and the function will return true
6+
Otherwise, he will think that the preparation is not enough and the function will return false
7+
*/
8+
29
function willSuccess(marks) {
310
if (!Array.isArray(marks)) {
411
return "Invalid";
@@ -19,6 +26,6 @@ function willSuccess(marks) {
1926
}
2027
return passSubject > failSubject;
2128
}
22-
const array = 90;
29+
const array = [60, 70, 80, 40, 30];
2330
const result = willSuccess(array);
2431
console.log(result);

F. Function/special-problem/marriage.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// Problem-4
1+
/* Problem-4
2+
3+
You need to write a function for a matrimony website. So that they can easily analyze the biodata of two people and understand whether marriage is possible between them or not. Whether marriage is possible between 2 people has to be determined based on some conditions.
4+
The 2 people have to be of different genders.
5+
The age difference between the 2 people cannot be more than 7 years. ( 💡explore Math.abs() )
6+
Your function will return true only if these conditions are met.
7+
*/
8+
29
function validProposal(person1, person2) {
310
if (typeof person1 !== 'object' || typeof person2 !== 'object') {
411
return "Invalid";
@@ -13,7 +20,7 @@ function validProposal(person1, person2) {
1320
return false;
1421
}
1522
}
16-
const person1 = { name: "toya", gender: "female", age: 24 };
17-
const person2 = { name: "bjoy", gender: "male", age: 32 };
23+
const person1 = { name: "Rahul", gender: "male", age: 28 };
24+
const person2 = { name: "Joya", gender: "female", age: 21 };
1825
const result = validProposal(person1, person2);
1926
console.log(result);

F. Function/special-problem/sleep-time.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
// Problem-5
1+
/* Problem-5
2+
3+
Shihab falls asleep while working in the office. Due to which he cannot finish all the work on time. He needs a function through which he wants to calculate the total time he slept in the office and then he wants to come home and do office work during that time.
4+
Your task is to create a function called calculateSleepTime(), which will take an Array as input. The Array will contain the number of seconds Shihab slept in. The function will extract the total time from the Array and convert it into hours, minutes and seconds and return it as an object.
5+
*/
6+
27
function calculateSleepTime(times) {
38
let sum = 0;
49
for (let time of times) {
5-
sum = sum + time;
610
if (typeof time !== 'number') {
711
return "Invalid";
812
}
13+
sum = sum + time;
914
}
1015
let hours = Math.floor(sum / 3600);
1116
let minutes = Math.floor((sum % 3600) / 60);

F. Function/special-problem/valid-phone.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
// Problem-2
1+
/* Problem-2
2+
Now your job is to create a function called validContact(), which will check whether a Contact number is valid based on some conditions. The conditions for a Contact number to be valid are
3+
The Contact Number must be 11 digits.
4+
The Contact Number must start with "01"
5+
There cannot be any spaces in the Contact Number.
6+
7+
If the above conditions are met, it will return true as the output. Otherwise, it will return false as the output.
8+
*/
9+
210
function validContact(contact) {
311
if (contact.length === 11 && contact.startsWith("01") && !contact.includes(" ")) {
412
return true;
@@ -10,5 +18,5 @@ function validContact(contact) {
1018
return false;
1119
}
1220
}
13-
const number = validContact(true);
21+
const number = validContact("01912345678");
1422
console.log(number);

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Problem-1
1+
/* Problem-1
2+
3+
Shihab is a smart businessman. Every day, his shop sells a lot of products, and a certain amount of VAT is added to each product. Shihab wants to keep the VAT of each product separately, rather than calculating the VAT of all products together, so that it is convenient to calculate it later.
4+
Since you are a skilled programmer, your job is to create a function called calculateVAT(), which will automatically calculate the VAT of a product when it receives the price of the product as input.
5+
VAT Rate: 7.5% */
6+
27
function calculateVAT(price) {
38
if (typeof price !== 'number' || price < 0) {
49
return "Invalid";

0 commit comments

Comments
 (0)