Start learning free

LESSON 170 OF 410 · PROJECTS: EVERYDAY PROGRAMS

Report Card V1 - One Subject Average in JavaScript

Practice

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, and test3 using Math.floor to drop the fraction (a plain / gives a decimal).
  • Print "Average: " followed by the average, for example console.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);

STEP 1 OF 2
    Ctrl + Enter to check

    Report Card V1 in JavaScript

    Keep going with JavaScriptAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free