Create a function/constructor for working with bank account data of a person.
Requirements:
-
The person has the following initial info: name, date of birth in string format, initial amount of money.
-
We can do the following options with person:
getInfo
- print into console info about the current personaddMoney
- plus money to his bank account and some info about transactionwithdrawMoney
- minus money from his account and some info about transactiongetAccountHistory
- print into console the history of managing his account -
Use
this
to describe these methods.
const dmytro = new Person('Dmytro', 1000);
const pavel = new Person('Pavel', 400);
dmytro.getInfo(); // print `Name: Dmytro, Amount: 1000$`
dmytro.addMoney(2000, 'salary');
dmytro.withdrawMoney(500, 'new phone');
dmytro.getInfo(); // Name: Dmytro, Amount: 2500$
dmytro.withdrawMoney(500, 'apartment rent');
dmytro.getAccountHistory(); // [ 'Initial: 1000', 'salary: 2000', 'new phone: -500', 'apartment rent: -500']
pavel.getInfo(); // // Name: Pavel, Amount: 400$