This code pattern is little bit confusing .. can you please tell me where i made the mistake .. it's hard to debug here?

This code pattern is little bit confusing … can you please tell me where i made the mistake … it’s hard to debug here ??

@Arnav7 your code? share it using cb ide