Question: I have some text in a pre tag with a fixed width and I need to count how many characters in each line of this chunk of text. 
For example, in the sample below first line has 80 characters, 2nd has 79, 3rd - 81 and so on. When we have an empty string with a newline it should be just 1.

```css
pre {
    display: block;
    white-space: pre-wrap;
    background: white;
    border-color: white;
    word-break: normal;
    width: 600px;
}
```

```html
<pre>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque suscipit, nisl eget dapibus condimentum, ipsum felis condimentum nisi, eget luctus est tortor vitae nunc. Nam ornare dictum augue, non bibendum sapien pulvinar ut. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras congue congue purus, quis imperdiet tellus ornare in. Nulla facilisi. Nulla elementum posuere odio ut ultricies. Nullam tempus tincidunt elit eget posuere. Pellentesque sit amet tellus sapien. Praesent sed iaculis turpis. Nam quis nibh diam, sed mattis orci. Nullam ornare adipiscing congue. In est orci, consectetur in feugiat non, consequat vitae dui. Mauris varius dui a dolor convallis iaculis.</pre>
```

Is this even possible to do?

Answer: 
You loop through the text and count until you found a line break element.
When you encounter a newLine character push count to array and start count from zero for new line

```
   input= document.getElementById("countDiv").innerHTML();
    var length = input.length;
    var lines=[]//number lines 
    var count=0;//counting character at each line
    for ( var i = 0; i < length; i ++ )
    {
    if (input.charAt(i)=='\n')
    {
    lines.push(count);
    count=0;
    }
    else{
    count=count+1;
    }

    }

```
Hello this is what I came up with.

```
//html
<pre id="countDiv">monkeyman</pre>
//JS
var x = document.getElementById("countDiv");
var y = x.innerHTML;
console.log(y.length);

```