WK1 Dino Island sample function "wrong values" error

I think I’ve got all the formulas coded correctly as well as the index update, but keep getting wrong values. Code and error attached.
Help would be appreciated.

{moderator edit - code removed}

Please do not post your code on the forum. That’s not allowed by the community standards.

If a mentor needs to see your code, they will ask you to send it via a private message.

I have edited your message to remove the code.

1st point: Your calculation of z is not correct. You’re using a_prev, that’s not the correct variable.

2nd point: Your calculation of idx may not be correct, but I don’t have time to test your code right now.

If you need additional help, please post a new thread, as I’m not able to reply further here (going offline for a few days).

Very sorry about posting the code.
Did not realize it was against the rules.
I’ll take a look at the formulas again, thanks.