In her early 20s, Sarah Robb O'Hagan was crushing it at work.
She was doing so well at her job at Virgin Atlantic that she was given a new role at Virgin Megastore.
"I get there and I think, 'I'm amazing, I've got this,'" O'Hagan told CNNMoney. "I didn't listen to anyone. I was just doing what I thought was right with very little grounding and knowledge."
Today, O'Hagan is CEO of the fitness company Flywheel Sports, a competitor to SoulCycle. But back then, she was in over her head, and her bosses noticed. She was fired and given one week's severance.
"I lost my green card application, my visa, everything," said O'Hagan, who is originally from New Zealand. "It was pretty devastating."
At first, O'Hagan wallowed. She ate ice cream and complained to her friends. But eventually, she stopped blaming Virgin for what happened and took responsibility for getting fired.
"If you acknowledge your role in something like this, you actually have control over how you move forward and don't make that mistake again," she said. "It's actually a very empowering feeling to take ownership for a big failure."
O'Hagan dusted herself off and started looking for jobs, and was hired by Atari. Two years later, she was laid off there.
In those years, her mid-to-late 20s, O'Hagan felt like she "could not get any wins on the board."
"It was a pretty horrifying experience," she said. While her peers were moving forward in their careers, she felt stuck. But then things took a turn.
Related: She was too short to play Goofy. Then she invented Spanx. Now she's a billionaire
Snakes and Ladders
After she was let go from Atari, O'Hagan landed a job at Nike (NKE). That's where "things really took off," she said.
"It's like Snakes and Ladders," O'Hagan explained. "You can catch up when you get back into the right environment."
"I loved Nike," she recalled. "I was on a great career trajectory." O'Hagan spent nearly six years at the company, holding management and director positions. But then she was offered a job as president of Gatorade, and, though the brand was struggling at the time, she took it.
"I knew when I left Nike that this was gonna be all or nothing, it was either gonna be a smashing success or an embarrassing failure," O'Hagan said. She knew that she'd probably never go back to Nike.
"It was terrifying," she said. But she took the risk.
Gatorade was in bad shape when O'Hagan got there. And at first, her efforts to turn the brand around made things worse.
In an effort to shake up Gatorade's image, O'Hagan led the charge to shorten the "Gatorade" logo to just "G" with a splashy Super Bowl campaign. After the launch, O'Hagan recalled, "sales went from flat to declining 20% every month."
"It was a pretty big disaster," she said.
But the repositioning of Gatorade from a sports drink to a "sports fuel" brand ultimately paid off. Gatorade leaned into the new identity, and sales started to increase.
Related: How Richard Branson went from high-school dropout to billionaire entrepreneur
Failure is the greatest personal trainer
O'Hagan was at Gatorade for four years before she became the president of Equinox and then the CEO of Flywheel. Her accomplishments, she said, have been possible because of her missteps.
"Failure is the greatest personal trainer that you will ever have," she said.
When she was at Gatorade, O'Hagan said, she would often think, "'I probably am gonna get fired over this, and I'm OK with that,' because I've been through that before. I've survived."
Risks "can lead to embarrassing failures," O'Hagan said. But "failure, once you get through it, will lead you somewhere better."
That's a lesson she hopes young people will take to heart.
"It really upsets me when I meet people who've been trained to think, 'I have to have everything look perfect and therefore I'm too scared to try,'" she said. "If you don't get over fear and try things, you don't even know what you're capable of."