I was prepared (my merit) but got lucky.

My merits:

I studied hard for full 4 months and then started applying for jobs. While applying, more 3 months of keeping studying until I got an offer.

By studying, I mean completing freecodecamp.org front end certificate. But also shipping small, learning projects. I had a portfolio. Pretty outdated by now as I haven't touched since I got a job: https://rodrigo-pontes.glitch.me

I also studied tech that is "hot". As I was studying to be a web developer, particularly frontend, I focused on React. No reason (I believe) for junior developers studying more established technologies. But back up the tech choice with data. In frontend world there are a LOT of jobs asking React. This is "hot". VueJS is promising, but you can't compare with where React is right now. Maybe in a year or two. Angular lost a lot of traction too, so no longer worthy. There a lot of places to find this data. It may be a ctrl+F at HN Who is hiring or look at Stack Overflow poll. Study the tech that has most job positions at the moment you are looking. Funny thing: I got hired to work with Ember. :) That's the thing, companies that work with not dominating techs know they are exceptions and are willing to introduce people to the tech. Companies that are working with the dominating tech will normally prefer people that know said tech and are less willing to introduce people to their tech.

I just applied for jobs I knew I was a good fit for. So in these 3 months, I believe I have applied to around ~15 jobs. But 10 of it were just a click on LinkedIn and I knew it mostly doesn't work. The other 5 were jobs that the first task was a code challenge. A much better bet in my opinion. It means that the company will actually take a look and a pay attention to your application and that the person taking a look are developers, not HR recruiters. This basically happens because the employers aren't flooded with applications, they knew it takes an effort to apply so they feel compelled to take it seriously. My job came from one of these 5 applications.

I prepared for the interviews by studying more than code, but also what was important to be a good developer. I read a lot of articles on this topic. My summary is: enjoy what you do (especially for people changing careers, don't do it just for the money), be prepared to keep studying all your life, be humble to always be learning from everyone, be good at communicating complex issues and teamwork. Also, I was very self-aware of my strengths: communication, work/study ethic, background in marketing (relevant as I was applying to be a web developer, mostly at startups) and my weaknesses: total lack of CS background (meaning I lack fundamental concepts in my education, like the architecture and design patterns basics), no experience as a developer in a professional environment (never worked on a code project within a team, no code reviews), very very basic Git knowledge.

All that means that I knew what to say during an interview. Always being honest and making sure that were aligned expectations and mutual understanding what kind and level of developer I was.

The luck part:

The company I was hired is a growing startup that had a recent crisis in its tech team, with a few developers leaving the company. This lead to a new CTO, a new tech team culture and an urgent need for growing its number of developer 4 times. So they were welcoming junior developers, in a very collaborative environment, with real, important tasks to do. I got lucky to find the right company at the right time (currently there are no more frontend junior positions around here).

I wrote more about my merits because it is something you can control. But I don't underestimate the lucky part. All horror stories of long-term unemployment we hear have a couple of close calls when the person almost got a job. If that close calls had pended to the right side for some arbitrary reason, there would be no horror story. That said, I believe there is a tip there to help you find the right company at the right time: look for companies that are putting real effort in hiring. Just a job post on some job boards? No. Find the ones that are starting with code challenges (as I said before), hosting and participating in meetups, have a very organized and updated careers page, explicitly state that they are hiring among their regular communication (Facebook, Linkedin, Twitter, etc). There are signs you can pick that a company is serious about hiring.