Skip to content
🛠️ Tools & Utilities mystery difficulty 1/5 🔥 0 next flip
 1  function wordCount(text) {
 2    const trimmed = text.trim();
 3    if (trimmed === '') return 0;
 4    const words = trimmed.split(/\s+/);
 5    return words.length;
 6  }
 7  // counts the words in a block of text
 8  const n = wordCount('  hello   there  world ');
 9  console.log(n); // 3

What does this function return for a blank string?

Playing free — sign in to save your streak.
🔥 streak
📣 Share card