string methods javascript count number of words inside a string
<html>
<body>
<script>
function countWords(str) {
str = str.replace(/(^\s*)|(\s*$)/gi,"");
str = str.replace(/[ ]{2,}/gi," ");
str = str.replace(/\n /,"\n");
return str.split(' ').length;
}
document.write(countWords(" Tutorix is one of the best E-learning platforms"));
</script>
</body>
</html>
Also in JavaScript:
- react callback
- javascript select element in dropdown
- javascript delete key from object
- nodejs map
- 'exceptionRenderer' => '\CrudJsonApi\Error\JsonApiExceptionRenderer',
- how to make a discord bot
- jquery loop through li element
- horizontal scrollview in react js
- generate random fractions with javascript
- map a square to a circle
- javascript bind multiple arguments
- how to use a js class in react
- hex string to int javascript
- javascript not empty array not string
- how to use await to console
- how to add toaster in angular 9
- js check proccess alive
- what is nodes and hubs in selenium grid
- pyspark from_json example
- jquery scroll to id
- remove disabled attribute javascript
- how to check palindrome in javascript for lowercase and uppercase
- jquery ajax form submission
- nodejs format text