-
Notifications
You must be signed in to change notification settings - Fork 0
/
atm.js
37 lines (31 loc) · 876 Bytes
/
atm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
const {pin, bal} = require("./account");
let newBal;
function getBalance() {
console.log(`Your current balance is $${bal}.`)
}
//I want newBal to equal the balance listed on account.js only the first time one of these functions is called:
function deposit(depositAmount) {
newBal = ~~bal + ~~depositAmount;
console.log(`Your deposit of $${depositAmount} has been completed. Your balance is now $${newBal}.`);
return newBal;
}
function withdraw(withdrawalAmount) {
newBal = ~~bal - ~~withdrawalAmount;
console.log(`Your withdrawal of $${withdrawalAmount} has been completed. Your balance is now $${newBal}.`);
return newBal;
}
function validatePin(enteredPin) {
if (enteredPin == pin) {
return true;
}
else if (enteredPin != pin) {
return false;
}
}
module.exports = {
getBalance,
deposit,
withdraw,
validatePin,
}