0Pricing
Javascript for Kids · Lesson

Longest Word

Find the longest.

Find the Longest Word! 📏

Hello, word champion! 📝 Today is a fun challenge: find the longest word in a sentence! 📏

Which word has the most letters? Let's teach the computer to find it! 🔍

Split First ✂️

To compare words, we first split the sentence into a list. ✂️

You know this trick now! split(' ') gives us our words. 📋

let sentence = 'the happy elephant';
let words = sentence.split(' ');
console.log(words);

All lessons in this course

  1. Splitting Text
  2. Counting Words
  3. Counting Letters
  4. Longest Word
← Back to Javascript for Kids