Question 2
Consider the following JavaScript code. What will be logged on to the console once the code is executed?
const stateManager = function () { let defaultState = false function alterState() { defaultState = !defaultState } return { currentState() { return defaultState }, changeState() { alterState() }, }}
const sm1 = stateManager()sm1.changeState()const sm2 = stateManager()
console.log(sm1.currentState(), sm2.currentState())true true
true false
false true
false false