Start learning free

LESSON 171 OF 410 · PROJECTS: EVERYDAY PROGRAMS

Report Card V2 - Weighted Score in JavaScript

Practice

Combine variables and arithmetic to compute a student's weighted final score.

Weights: Homework 20%, Midterm 30%, Final 50%. Each weighted part is rounded down to a whole number before the parts are added.

You start with:

const homework = 90;
const midterm = 82;
const final_ = 88;

Build:

Score: 86

Rules:

  • Compute score = Math.floor(homework * 20 / 100) + Math.floor(midterm * 30 / 100) + Math.floor(final_ * 50 / 100).
  • Each part is rounded down with Math.floor (the third variable is named final_).
  • For the starting data: 18 + 24 + 44 = 86.
  • Print "Score: " followed by the score, for example console.log("Score: " + score);

The third variable is named final_. Wrap each part in Math.floor(...), for example Math.floor(homework * 20 / 100).

const homework = 90;
const midterm = 82;
const final_ = 88;

const score = Math.floor(homework * 20 / 100) + Math.floor(midterm * 30 / 100) + Math.floor(final_ * 50 / 100);
console.log("Score: " + score);

STEP 1 OF 2
    Ctrl + Enter to check

    Report Card V2 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