Skip to content

Instantly share code, notes, and snippets.

@sergiopichardo
Created July 30, 2021 01:48
Show Gist options
  • Select an option

  • Save sergiopichardo/d1c8053bdfc8dfdb62d2b2a271108d11 to your computer and use it in GitHub Desktop.

Select an option

Save sergiopichardo/d1c8053bdfc8dfdb62d2b2a271108d11 to your computer and use it in GitHub Desktop.

Revisions

  1. sergiopichardo created this gist Jul 30, 2021.
    22 changes: 22 additions & 0 deletions preserveContextSolution4.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    class Employee {
    constructor(name, lastName, salary) {
    this.name = name;
    this.lastName = lastName;
    this.salary = salary;
    }

    getSalaryInfo() {
    const calculateMonthlyWages = () => {
    return {
    name: this.name + ' ' + this.lastName,
    monthlyWages: this.salary / 12,
    salary: this.salary
    }
    }

    return calculateMonthlyWages();
    }
    }

    const alexis = new Employee('Alexis', 'Rose', 500_000)
    console.log(alexis.getSalaryInfo());