I need Help.... I do not find the error in this code but the result variable be undefined

The code is in the back-end and the function is called from the front-end; and The truth is that I don’t know exactly what it means to debug the function. I imagine that what you put is to try different variables given from the Json code and see if they all work or not… but I would need more data. Thank you.