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

Related Posts

More content you might like

Tutorial
javascript

Primitive Data Types

The null value represents an intentional absence of any object value.

  let currentUser = null;
  console.log(currentUser); // null

Dec 11, 2024
Read More
Code
javascript python +1

Generate Random Password

No preview available for this content.

Jan 26, 2024
Read More
Code
javascript python

Reversing a String in JavaScript: A Simple Guide

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!