Student Performance Analysis
Programming Basics · JavaScript
TASK
Problem
Given three scores 0..100. Print their average and status: EXCELLENT ≥90, GOOD ≥75, PASS ≥60, otherwise FAIL.
EXAMPLE
Example
90 80 85
85.0 GOOD
LIMITS
Constraints
0≤score≤100
LEARN
Theory for this problem
+
### Student Performance Analysis
JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.
NEED HELP?
Hints
+
['Write the formula using named intermediate values if it contains more than one operation.', 'Consider a repeated key or value: the data structure must update exactly as required by the statement.']
ANSWER
Solution
+
const fs = require('fs');
const [a, b, c] = fs.readFileSync(0, 'utf8').trim().split(/\s+/).map(Number);
const average = (a + b + c) / 3;
let status;
if (average >= 90) {
status = 'EXCELLENT';
} else if (average >= 75) {
status = 'GOOD';
} else if (average >= 60) {
status = 'PASS';
} else {
status = 'FAIL';
}
const formattedAverage = Number.isInteger(average)
? average.toFixed(1)
: String(average);
console.log(formattedAverage, status);