RippleHire interview question

Modify a code snippet for the given output