Please enable JavaScript to use CodeHS

CodeHS Glossary


Break Down (Decompose) JavaScript

Breaking down your code is splitting it into more functions. It is also called decomposing your code. Having your code broken down well is called having good "decomposition." You often want to break down your code to make it more readable, avoid repeating code, and to simplify your program. For example, if your code looks like this: function start() { move(); move(); move(); takeBall(); turnAround(); move(); move(); move(); } you would want to "break it down" into functions, so the start function looks like this: function start() { moveToBall(); takeBall(); returnHome(); } By breaking the code down, the program is much easier to read and [tells more of a story][1]. [1]: http://codehs.com/glossary/term/9