I have a blob of text like this, called body
:
images: OK
default: OK
...
So I'm trying to work with it concisely, like so:
for (str in body.split('\n')) {
console.log(str);
}
but I just get a list of numbers (the indices of each element). Why is this happening? Further more, I can't seem to do filter functions on this because of this behavior:
body.split('\n').filter(function(str){ return str && str.length > 0; });
just returns the whole array even if there are empty elements.