Compute an end-of-year performance bonus for one employee, then print the employee's name and the bonus.
You start with:
const name: string = "John Doe";
const productivity: number = 83;
const salary: number = 135000;
Build:
John Doe Bonus: $20250
Rules:
- The bonus is 15% of the
salary, rounded down to a whole number. - Print the employee's
nameon the first line. - Print the bonus on the second line as
"Bonus: $<amount>". productivityis 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: number = Math.floor(salary * 15 / 100);
+ turns the number into text: console.log("Bonus: $" + bonus);
const name: string = "John Doe";
const productivity: number = 83;
const salary: number = 135000;
const bonus: number = Math.floor(salary * 15 / 100);
console.log(name);
console.log("Bonus: $" + bonus);
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
