Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions module-1/classification.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @returns {number} grade or 0 if any arguments are not proper
*/
function grade(score) {
let gradeOfStudent;
/*
* Your task is to calculate the grade of the student
* based on his/her score which can be found in the
Expand All @@ -20,9 +19,6 @@ function grade(score) {
* Store the grade in the gradeOfStudent variable.
* Also take into consideration the documentation of the function!
*/
// PLACE YOUR CODE BETWEEN THIS...

// ...AND THIS COMMENT LINE!
return gradeOfStudent;
return (score > 100 ? 0 : score >= 90 ? 5 : score >= 80 ? 4 : score >= 70 ? 3 : score >= 60 ? 2 : score < 0 ? 0 : 1);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I know this looks kinda horrible, but in the webinar ppt it said that try to use 1 expression to solve the classification. So here is my try.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also check how Math.ceil(), Math.min() and Math.max() are working,

}
module.exports = grade;
16 changes: 11 additions & 5 deletions module-1/euclidean.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@
* @returns {number} GCD or 0 if any arguments are not proper
*/
function euclidean(a, b) {
let gcd;
/*
* Your task is to compute the greatest common divisor of
* the numbers given in a and b variables, using the
* Euclidean algorithm (https://en.wikipedia.org/wiki/Euclidean_algorithm).
* If you have the result, assign it to the variable, called gcd.
* Also take into consideration the documentation of the function!
*/
// PLACE YOUR CODE BETWEEN THIS...
if (a <= 0 || b <= 0) {
return 0;
}


// ...AND THIS COMMENT LINE!
return gcd;
while (a !== b) {
if (a > b) {
a -= b;
} else {
b -= a;
}
}
return a;
}
module.exports = euclidean;
9 changes: 9 additions & 0 deletions module-1/fibonacci.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ function fibonacci(n) {
*/
// PLACE YOUR CODE BETWEEN THIS...

if (n < 0) {
return 0
}

if (n < 2) {
nThFibonacci = n
} else {
nThFibonacci = fibonacci(n-2)+fibonacci(n-1)
}
// ...AND THIS COMMENT LINE!
return nThFibonacci;
}
Expand Down