https://www.codewars.com/kata/5ad0d8356165e63c140014d4
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Create a function finalGrade, which calculates the final grade of a student depending on two parameters: a grade for the exam and a number of completed projects.
This function should take two arguments: exam - grade for exam (from 0 to 100); projects - number of completed projects (from 0 and above);
This function should return a number (final grade). There are four types of final grades:
- 100, if a grade for the exam is more than 90 or if a number of completed projects more than 10.
- 90, if a grade for the exam is more than 75 and if a number of completed projects is minimum 5.
- 75, if a grade for the exam is more than 50 and if a number of completed projects is minimum 2.
- 0, in other cases
Examples(Inputs-->Output):
100, 12 --> 100
99, 0 --> 100
10, 15 --> 100
85, 5 --> 90
55, 3 --> 75
55, 0 --> 0
20, 2 --> 0
*Use Comparison and Logical Operators.
코드
function finalGrade (exam, projects) {
return exam > 90 || projects > 10 ? 100 : exam > 75 && projects >= 5 ? 90 : exam > 50 && projects >= 2 ? 75 : 0;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] What is between? (8 kyu) / JavaScript (0) | 2023.04.14 |
---|---|
[Codewars] Reverse List Order (8 kyu) / JavaScript (0) | 2023.04.13 |
[Codewars] Cat years, Dog years (8 kyu) / JavaScript (0) | 2023.04.12 |
[Codewars] Area of a Square (8 kyu) / JavaScript (0) | 2023.04.12 |
[Codewars] Correct the mistakes of the character recognition software (8 kyu) / JavaScript (0) | 2023.04.11 |
댓글