What is the function of heart valves?

What is the function of heart valves?