For JS, an array of text is set in the arr variable:
let arr = ["When I consider every thing that grows",
"",
"Holds in perfection but a little moment,",
"",
"That this huge stage presenteth nought but shows",
"",
"Whereon the stars in secret influence comment;"];
How to remove the empty lines from it, and that it remains as an array, but without the empty strings:

You can use a boolean filter for this:
arr.filter(Boolean)
Full Code:
let arr = [
"When I consider every thing that grows",
"",
"Holds in perfection but a little moment,",
"",
"That this huge stage presenteth nought but shows",
"",
"Whereon the stars in secret influence comment;"
];
console.log(arr.filter(Boolean));
Gives me:
[
"When I consider every thing that grows",
"Holds in perfection but a little moment,",
"That this huge stage presenteth nought but shows",
"Whereon the stars in secret influence comment;"
]