How do you learn to use less code for the same solutions?

Im a little bummed when i solve an FCC challenge because when I check other solutions I always find neater and shorter code used to do just the same thing i’ve done.

Is it simply experience or i’m not trying hard enough? How do you achieve the same things with less code?

I think it is the experience in writing
If you do a long code try to use For loop or While loop , use more If Else , for the neater code just there is some rules to make stuff looks better like

hope somebody reply for you too as i also need to know more :slight_smile:

1 Like

Use the new arrow (=>) syntax in ES6. Avoid intermediate variables for assignments. Learn functional programming. Kyle Simpson has a new book about FP in JavaScript:

It’s on my list.

1 Like

It’s simply experience. And a lot of that experience will just be knowing where and how to look more efficiently for new ideas. After discovering FCC I realize that I have a bazillion things to learn myself.

1 Like

It’s being aware that there are X and Y commands you can use, and this only comes from

a. being exposed and reading other people’s code and learning from it.

b. reading the language reference manual/documentation in your spare time to become familiar what X and Y commands are available.

1 Like