You are checking wether the current count is larger or equals to your variable countDadJokes.
while count >= self.countDadJokes
Then inside the loop you increase the count variable. In my understanding you would want to check if the count is lower than countDadJokes.
With this line:
UserDefaults.standard.setValue(self.dadJokes, forKey: "dadJoke")
you are also overwriting what you changed in the last iteration of the loop.
When you say
Why is this loop not working
please tell us what exactly isn't working.