var userSelection
function countLineBreaks(){
//Textarea
var textarea = document.getElementById("textArea");
//Get user selection
userSelection = (textarea.value).substring(textarea.selectionStart,textarea.selectionEnd);
//Simple regex to check for line break
var matches = userSelection.match(/
/g);
//Count line breaks
var lineBreaksCount = matches ? matches.length : 0
console.log(lineBreaksCount + ' Line breaks')
}