Explorer
Node.js

Write a function `getGrade(score)` that returns "A" for score >= 90, "B" for >= 80, "C" for >= 70, "D" for >= 60, "F" otherwise.

Problem Statement

Write a function `getGrade(score)` that returns "A" for score >= 90, "B" for >= 80, "C" for >= 70, "D" for >= 60, "F" otherwise.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: You can use if-else chains or ternary operators. šŸ’” Hint 2: Ternary: condition ? valueIfTrue : valueIfFalse. šŸ’” Hint 3: Nest ternaries or use if-else for multiple ranges. āœ… Solution: ```javascript function getGrade(score) { if (score >= 90) return "A"; if (score >= 80) return "B"; if (score >= 70) return "C"; if (score >= 60) return "D"; return "F"; } ```

Ternary and Short-circuit Evaluation

Easy
Write a function `getGrade(score)` that returns "A" for score >= 90, "B" for >= 80, "C" for >= 70, "D" for >= 60, "F" otherwise.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
["A","B","C","D","F"]