0Pricing
Javascript for Kids · Lesson

What Is a Code?

Hide messages.

What Is a Code? is a free Javascript for Kids lesson on CoddyKit — lesson 1 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.

Secret Messages! 🕵️

Welcome, secret agent! 🕵️ In Secret Code Maker we learn to hide messages so only your friends can read them! 🤫

console.log('Top secret mission starting! 🕵️')

What Is a Code? 🔐

A code changes a message so others can't understand it. Like turning HI into JK! 🔐

console.log('HI becomes a secret! 🔐')

Why Use Codes? 🤔

Spies, treasure maps, and secret clubs all use codes so only the right people understand. 🗺️

console.log('Only my friends can read this! 🤫')

A Message Is Text 📝

In code, a message is just text stored in a variable. 📝

let message = 'hello'
console.log('My message is:', message)

Text Has a Length 📏

We can count the letters with .length. 📏

let message = 'hello'
console.log('Letters:', message.length)

Pick One Letter 🔤

We can grab a single letter using its position. The first letter is position 0! 🔤

let message = 'hello'
console.log('First letter:', message[0])

Loop Through Letters 🔁

To change a message, we look at each letter one by one with a loop. 🔁

let message = 'hi'
for (let i = 0; i < message.length; i++) {
  console.log(message[i])
}

Letters Have Numbers 🔢

Every letter secretly has a number! charCodeAt shows it. The letter a is 97. 🔢

console.log('a is number', 'a'.charCodeAt(0))
console.log('b is number', 'b'.charCodeAt(0))

Numbers Back to Letters 🔄

We can turn a number back into a letter with String.fromCharCode! 🔄

console.log(String.fromCharCode(97))
console.log(String.fromCharCode(98))

The Big Idea 💡

To make a code, we change each letter's number a little bit. That's the secret of a cipher! 💡

let n = 'a'.charCodeAt(0)
console.log('Shift a by 1:', String.fromCharCode(n + 1))

Glue Letters Together 🧩

We build the secret message by joining letters with +. 🧩

let secret = ''
secret = secret + 'X'
secret = secret + 'Y'
console.log('Secret so far:', secret)

Quick Check ✅

Test your spy skills! 🕵️

Code Cadet! 🌟

Great start, agent! 🕵️ You learned what a code is! 🎉

  • Codes hide messages 🔐
  • Letters have secret numbers 🔢
  • We can loop through letters 🔁

Next: shifting letters! ➡️

console.log('What is a code: LEARNED! 🌟')

Frequently asked questions

Is the “What Is a Code?” lesson free?

Yes — the full text of “What Is a Code?” 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 “What Is a Code?”?

Hide messages. 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 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “What Is a Code?” 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

  1. What Is a Code?
  2. Shifting Letters
  3. Encoding
  4. Decoding
← Back to Javascript for Kids