Skip to content

Instantly share code, notes, and snippets.

@dleitee
Last active March 14, 2017 01:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleitee/a6de53cb3442832fa39cc39c38250155 to your computer and use it in GitHub Desktop.
Save dleitee/a6de53cb3442832fa39cc39c38250155 to your computer and use it in GitHub Desktop.
const account = {
balance: 1000,
bank: '',
number: '',
}
const deposit = (account, value) => {
return {
...account,
balance: account.balance + value,
}
}
deposit(account, 1000) // returns an account with balance = 2000
deposit(account, 1000) // still returns an account with balance = 2000
deposit(account, 1000) // no matter what happens, always will returns an account with balance = 2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment