Here are some KEY ideas behind writing clean code.

I have kept the list small so that it's actionable.

(1) Reduce comments to a minimum.

Add comments only when needed as they take time to read.

They can confuse the reader if they are not written properly or the code has changed.

Make your code self-documenting instead. More on this below.

(2) Use compact, descriptive variable/function names.

x is a bad name. Too short and not meaningful.

totalNumberOfSalesInDiwali is a bad name. Too long, takes time to read and understand.

diwaliSaleCount is a better name. Has a great balance of reading time and understandability.

(3) Functions and methods should do only one thing

This makes code more modular which increases code reuse, improves code testability, and understandability.

If the name of a function doesn’t completely describe what it does, it’s a badly written function and needs to be broken down.

(4) One file contains only one "thing". Create as many files as needed.

This makes your code more understandable from the file-level and is better w.r.t merge conflicts.

(5) Consistent indentation. Use an automatic formatter if needed.

There’s no reason to not have your indentation on point especially when auto-formatting tools like Prettier are available. Use them.