Whitespace
In programming, whitespace uses horizontal and vertical space characters or blank lines to format code and improve readability.
Example
The code example below is hard to read since there is little to no whitespace. It also does not have indentation with spaces so people can not easily see what is nested within what.
function createRangeIterator(min = 0, max = Infinity, step = 1) {let nextNum = min;let numCount = 0;const rangeIterator = {next: function () {let result;if (nextNum < max) {result = { value: nextNum, done: false };nextNum += step;numCount++;return result;}return { value: numCount, done: true };},};return rangeIterator;}
When whitespace is used, the code is much more readable:
function createRangeIterator(min = 0, max = Infinity, step = 1) {let nextNum = min;let numCount = 0;const rangeIterator = {next: function () {let result;if (nextNum < max) {result = { value: nextNum, done: false };nextNum += step;numCount++;return result;}return { value: numCount, done: true };},};return rangeIterator;}
All contributors
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.