I am trying to pass in the insertError
function parameter the type of action that needs to take place.
insertErrorClass(val, action) {
val.classList.action(classNames.INVALID);
}
Example:
insertErrorClass(val, 'add') {
val.classList.add(classNames.INVALID);
}
insertErrorClass(val, 'remove') {
val.classList.remove(classNames.INVALID);
}
I can do it using if
statements, but was wondering if there was more efficient way of doing it.