Counting Letters
Count characters.
Counting Letters is a free Javascript for Kids lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Javascript for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Counting Letters! 🔠
Hello again, word wizard! 📝 We counted words, now let's count letters! 🔠
How many letters are in your name? Let's teach the computer to count them! 🤖
Letters Have Length Too 📏
Guess what? Strings have .length just like arrays! 📏
For a string, .length counts the characters (letters)! 🔠
let word = 'cat';
console.log('Letters in cat: ' + word.length);Count Your Name 🙋
Let's count the letters in a name! 🙋
Change the name to your own and run it! How many letters do you have? 😄
let name = 'Maya';
console.log(name + ' has ' + name.length + ' letters!');Spaces Count Too! 🫧
Careful! Spaces are characters too! 🫧
In 'I am', the space between counts as 1 character. So it has 4 characters! 🔢
let phrase = 'I am';
console.log('Characters (with space): ' + phrase.length);A Letter Counter 🛠️
Let's make a letter-counting machine! 🛠️
Give it a word, get back the letter count! 🤖
function countLetters(word) {
return word.length;
}
console.log(countLetters('apple'));
console.log(countLetters('sun'));Count Without Spaces 🚫🫧
What if we want letters only, no spaces? 🚫🫧
We split into words, then add up each word's length! Watch this trick! 🪄
let sentence = 'big red dog';
let noSpaces = sentence.split(' ').join('');
console.log('Without spaces: ' + noSpaces);
console.log('Letters only: ' + noSpaces.length);Join Brings Words Together 🤝
Did you see join('')? It is the opposite of split! 🤝
It glues the pieces back together with no spaces between them. 🪄
let words = ['I', 'love', 'code'];
let glued = words.join('');
console.log(glued);
console.log('Total letters: ' + glued.length);Words AND Letters 📊
Let's count BOTH words and letters at once! 📊
Now our counter is super powerful! 💪
let sentence = 'I love coding';
let words = sentence.split(' ');
let letters = sentence.split(' ').join('');
console.log('Words: ' + words.length);
console.log('Letters: ' + letters.length);Find the Biggest Word? 🤔
Counting letters helps us compare words! 🤔
Let's check which word has more letters. 'elephant' or 'ant'? 🐘🐜
let word1 = 'elephant';
let word2 = 'ant';
console.log(word1 + ' has ' + word1.length + ' letters');
console.log(word2 + ' has ' + word2.length + ' letters');
if (word1.length > word2.length) {
console.log(word1 + ' is longer! 🐘');
}A Friendly Report 💬
Let's make a friendly letter report! 💬
It tells the player both the word and the letter count! 😄
function letterReport(word) {
console.log('🔠 The word: ' + word);
console.log('✏️ Letters: ' + word.length);
}
letterReport('rainbow');You Can Count Letters! 🏆
Wonderful! 🏆 You learned to count letters!
- 📏 Strings have
.lengthtoo - 🫧 Spaces count as characters
- 🤝
join('')removes spaces
Next: finding the LONGEST word! 📏
Quick Check ✅
Brain check! 🧠 What does word.length tell us for a string like 'dog'?
Lesson Recap 🎀
Great work, letter counter! 🎀 Today you learned:
- 📏 Strings have
.length - 🫧 Spaces are characters too
- 🤝
join('')glues pieces together - 🐘 Compare lengths to find longer words
Next: the longest word challenge! 📏
Frequently asked questions
Is the “Counting Letters” lesson free?
Yes — the full text of “Counting Letters” is free to read here on the web, and the Javascript for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Javascript for Kids course, upgrade to CoddyKit PRO.
What will I learn in “Counting Letters”?
Count characters. You practise Javascript for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Javascript for Kids?
No prior experience is required. Javascript for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Counting Letters” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Javascript for Kids lesson?
Yes. Every Javascript for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Splitting Text
- Counting Words
- Counting Letters
- Longest Word