Utilize regular expressions to detect and substitute patterns within a string. For example:
value.replace(/(\n\n?)\n+/g, '$1');
var input = document.getElementById('input'),
output = document.getElementById('output');
output.value = input.value.replace(/(\n\n?)\n+/g, '$1');
textarea { height: 180px; float: left; }
<textarea id="input">
one return
two returns
three returns
four returns
</textarea>
<textarea id="output"></textarea>
» Check out Regex 101 for more information.
edit: The initial explanation was ambiguous. Merely removing one line break at a time may not be practical in real-world scenarios, so the original response remains unchanged. Regarding the request to delete a single blank line when there are three or four consecutive blank lines...
value.replace(/(\n*)\n/g, '$1');
var input = document.getElementById('input'),
output = document.getElementById('output');
output.value = input.value.replace(/(\n*)\n/g, '$1');
textarea { height: 180px; float: left; }
<textarea id="input">
one return
two returns
three returns
four returns
</textarea>
<textarea id="output"></textarea>