It’s most likely because you haven’t declared a. You’re increasing a with one, but a doesn’t exist. Therefore it doesn’t work.
Another thing to remember is that the data might not be loaded yet when that button is being pressed. It is safer to only set the onPress handler when the file has loaded. This is done using onLoad: