See
this post. Salvin pointed out that we usually don't provide complete solutions, but he perceived the original poster (=OP) having difficulties. This was obviously a case where the OP would only have tied themselves in knots and a bit of code would get them out of their difficulties. We apply the rule about not providing solutions most strictly in the “
BJ” forum. It is a nice point of judgement, but Salvin thought OP was getting stuck in the mud and allowing them to struggle would simply have led to them getting in deeper and deeper.