Last active
June 8, 2021 02:34
-
-
Save iampava/b1d7e39d394f48a41ce10f6338dc988a to your computer and use it in GitHub Desktop.
Hacking Javascript |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PiggyBank(){ | |
let money = []; | |
return { | |
store: function(index, value){ | |
money[index] = value; | |
}, | |
push: function(value){ | |
money.push(value); | |
} | |
} | |
} | |
let sharedPiggyBank = PiggyBank(); | |
// Mom gives the sharedPiggyBank to Bob & Alice | |
// But, there's a weakness in this code which allows direct access to the money Array. | |
// Can you spot it? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment