DeveloperBreeze

JavaScript Word Count in a Sentence

javascript
// 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);

Continue Reading

Handpicked posts just for you — based on your current read.

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!