Published on January 26, 2024By DeveloperBreeze

// Input sentence
const sentence = 'This is a sample sentence.';

// Calculate word count by splitting the sentence at spaces
const wordCount = sentence.split(' ').length;

// Display the word count
console.log('Word Count:', wordCount);

Comments

Please log in to leave a comment.

Continue Reading:

Reversing a String in JavaScript: A Simple Guide

Published on January 26, 2024

javascriptpython

Generate Random Password

Published on January 26, 2024

javascriptpythonphp

Primitive Data Types

Published on December 11, 2024

javascript