Well, since the instructions say you have to use a for loop then your options for making this “better” are pretty limited But you do technically have an unnecessary variable in there that you can get rid of. I think maybe you have it in there for the sake of the console.log?
Not making it better but using indexOf feels a little bit “cheaty” to me. I’d rather see another for loop myself to show full understanding of the topic. Just my two cents!
On the topic of clean code I can highly recommend the book “Clean Code” by Robert Martin. The examples are all in Java but the principles are sound. I’ve been a professional developer for 27 years, and reading it at the moment is making me change the way I code. We are always learning in this industry.