K Health interview question

Technical interview - Build a complex JS function.