Implement a function useToggle(initialValue) that manages a boolean state and allows toggling it.
The function should:
value: current boolean state.toggle: function that switches the state from true to false or false to true.setTrue: function to set the state to true.setFalse: function to set the state to false.Example
const toggle = useToggle(false); toggle.value; // false toggle.toggle(); toggle.value; // true toggle.setFalse(); toggle.value; // false
JavaScript Function
No test results yet
Click "Run" to execute tests