I had failure with business for about 2 years before the first exit. There was a chain of events from my first business failure to my actual first business win... I learned actual gritty sales skill on the first failure, and met with my partner who admired my persistence and research.
We had a lot of bad ideas, but we pivoted the core gradually towards something that worked. My first idea and the final product had nothing at all in common, except for being in the food industry.
That same idea was acquired by a team with far more resources, better skills, more experience, better market and timing... but it didn't work because the new team wasn't focused enough. The only major difference was the amount of energy put into it.
The foundation of it is really just building something that someone wants. As long as you stick to that foundation, you will continue to build upon something of value. As long as you build something of value, you have an asset, that can be sold to the right buyer.
Quoting Paul Graham: "If you can just avoid dying, you get rich. That sounds like a joke, but it's actually a pretty good description of what happens in a typical startup. It certainly describes what happened in Viaweb. We avoided dying till we got rich."