Find if a key exists in association list

Hello, I have an association list and I want to search if it has a certain key in it.
My code is like:
//if key exists do this
//else do that

But it doesn’t work. I need your proposals.

I spotted this on stackoverflow before here, so have answered there.