# 3. Deteriorate the code

Imagine walking into a messy room and being tasked with adding your own belongings to it. Many people would simply throw their things in and call it a day, but that only adds to the clutter. The right approach is to organize the area where you're adding something. For example, if it's clothes, tidy up the closet, put all the clothes in there, and then place your item in its designated spot. Always strive to improve the code, but never make it worse.

Here are a few common mistakes that lead to cluttered code:

#### Duplicating&#x20;

Copying code just to change one line creates a mess. It's like buying chairs of different heights for different occasions instead of buying one with an adjustable seat. Keep the abstractions in your head and adjust them for different needs to simplify the code.



**Not using a configuration file**

\
Values that may vary depending on the environment should be placed in a configuration file, instead of scattered throughout the code. Every time you enter a new value into the code, ask yourself: "should I put it in the configuration file?" The answer will almost always be yes.

Unnecessary conditional operators and temporary variables

\
If branches affect the logic of your program, so their presence should be minimized without harming readability. The tricky part is determining the right level to change: should you extend the current code or take it to an external function and call it?



Here is a prime example of an unnecessary if:\


```
function isOdd(number) {
 if (number % 2 === 1) {
   return true;
 } else {
   return false;
 }
}
```

\
It could be rewritten without a single if:

```
function isOdd(number) {
 return (number % 2 === 1);
};
```
