Start learning free

LESSON 56 OF 410 · CALCULATIONS - CHALLENGES

Employee of the Year V1 - Project in JavaScript

Practice

Compute an end-of-year performance bonus for one employee, then print the employee's name and the bonus.

You start with:

const name = "John Doe";
const productivity = 83;
const salary = 135000;

Build:

John Doe
Bonus: $20250

Rules:

  • The bonus is 15% of the salary, rounded down to a whole number.
  • Print the employee's name on the first line.
  • Print the bonus on the second line as "Bonus: $<amount>".
  • productivity is not used in this version. It is there for the next versions, where you will compare employees by productivity.

Use Math.floor to round the 15% down to a whole number: const bonus = Math.floor(salary * 15 / 100);

+ turns the number into text: console.log("Bonus: $" + bonus);

const name = "John Doe";
const productivity = 83;
const salary = 135000;

const bonus = Math.floor(salary * 15 / 100);
console.log(name);
console.log("Bonus: $" + bonus);

STEP 1 OF 3
    Ctrl + Enter to check

    Employee Of The Year 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