I want to count number of sentences and Words in each sentence. This code is counting the sentences but I want to split the text by each sentence to put into an array. Kindly suggest me some better mechanism.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Count Number of Words in a String</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
var words = $.trim($("textarea").val()).split(".");
alert(words.length-1);
});
});
</script>
</head>
<body>
<textarea cols="50">The quick brown fox jumps. over the lazy dog.</textarea>
<br>
<button type="button">Count Words</button>
</body>
</html>