DEV Community

Harit Himanshu
Harit Himanshu

Posted on

Answer: Is this a valid use case for javascript closure?

I was trying to come up with a practical example of information-hiding/encapsulation and this is what my attempt so far

'use strict';

const bank = (accountHolderName, initialDeposit) => {
    let balance = initialDeposit;
    const add = (amount) => {
        balance += amount;
    }

    let subtract = (amount) => {
        balance

Top comments (0)