Compute a student's average score across three tests using integer division so the result is a whole number.
You start with:
const test1 = 85;
const test2 = 92;
const test3 = 78;
Build:
Average: 85
Rules:
- Compute the integer average of
test1,test2, andtest3usingMath.floorto drop the fraction (a plain/gives a decimal). - Print
"Average: "followed by the average, for exampleconsole.log("Average: " + average);
Use
Math.floor((test1 + test2 + test3) / 3) to get an integer average.
const test1 = 85;
const test2 = 92;
const test3 = 78;
const average = Math.floor((test1 + test2 + test3) / 3);
console.log("Average: " + average);
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
