If you read the replies to my post you will see answers from posters who contradict each other or they are incomplete which indicates to me they don't fully understand.
This is another really valuable observation.
Once you understand the rules and syntax of code structure, you will soon realise there’s always three or more ways to solve the same programming problem.
While(), for(), nested loops, switch-case vs if/else and so-on.
There are countless options which can only be understood after two or more YEARS of exposure to different ciding styles by different people. There is not one ‘right’ way, but some are better than others (and faster, portable, more reliable and readable)!
How you apply that code, and choose one method over another comes down to personal preferences, habit, urgency, readability and that magical ‘elegance’ touted by many seasoned developers.
(Joke: Elegance, often involves coding for the least number of compute cycles in the least relevant part of the program!)