I have a website on which users can ask a question & also they can answer it.

So, when a user asks a question, it creates a new web-page on the website & below that question lies it's answers (if any).

I don't want search engines to index those pages (or questions) which doesn't have an answer, so I added a if condition, stating if the question don't have answer show the noindex meta tag, if it does, then don't show it (so that google can index now).

I was wondering if it the right way to do so?

I mean, first when the question is asked & google will crawl it, it will see the noindex tag. But after some time when it will have an answer google will see that it can be index.

So, will it affect the ranking & overall performance in google search results?