Using Either for error handling in functional JavaScript programming