JavaScript, Code Quality.
best of luck you will end up writing mini JS library. so what we can do? one way keep the state in another function and pass the function return value to validate function this way your state value will be local and you can pass or overwrite the value without disturb another functionality. oh are