Create a function called useBoolean
that manages a boolean state.
The function should return an object with:
value
: the current boolean valuesetTrue
: a function to set the value to truesetFalse
: a function to set the value to falsetoggle
: a function to toggle the valueExample:
const { value, setTrue, setFalse, toggle } = useBoolean(false); // value is false initially setTrue(); // value becomes true toggle(); // value becomes false setFalse(); // value stays false
JavaScript Function
No test results yet
Click "Run" to execute tests