it's not bad, it depends what you want the code to do.
your loop will take some time, meaning the system won't go back to the main function and perform some other work as often as if you had used an if. On some arduinos, if you are stuck for too long in a while loop, it might trigger the watchdog and reboot the arduino...
another example is if you test the state of a button at the start of the loop, and you have a long lasting while (blocking code basically) inside the loop, you won't come back and check the button again soon...
so that's why you got that advice - but it's a general recommendation, your mileage may vary. it's totally OK to have a short for or while loop within the loop() function
I have actually used loops inside loop function and never faced a problem. But since I have been advised against I am scared of continuing the practice, but I don't get why is this practice advised against.
Using while loops or for loops inside the loop() function will inevitably slow down how fast the code in the loop() function is repeated.
Suppose that you read the state of an input in the loop() function and need to do so frequently in order to detect an input and react to it, perhaps to prevent a moving object going too far along a track. Would you want that to be delayed by a while loop that takes a significant time to execute ?
Of course, this may not be relevant to your projects but it is good practice to program in a defensive way that will prevent future problems occurring
Till now I have used while loops only when I do not need anything else to be done. But because my while loop might be going on for like 7-19 seconds, and I have heard advises like the one given by @J-M-L quoted below, I am scared of using the While Loop even though its often the more attractive path (lines of code are significantly reduced with while loops). So maybe will just stick with if-else as an excess of caution.
You can only trigger a watchdog time out if you actually turn on the watch dog yourself. It won't happen by its self, it takes some setting up to get them going.