0Pricing
Javascript for Kids · Lesson

Encoding

Text to code.

Encoding 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.

Make It Secret! 🔐

Encoding means turning a normal message into a secret one. Let's become master code makers! 🔐🕵️

console.log('Time to encode a message! 🔐')

Start With a Message 📝

First we need a message to hide. 📝

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

Pick a Secret Shift 🔢

Choose a shift amount. This is like the secret key only friends know! 🔢🗝️

let shift = 3
console.log('Secret shift key:', shift)

Empty Secret Box 📦

We start with an empty string to collect our secret letters. 📦

let secret = ''
console.log('Secret box is empty for now:', secret)

Shift One Letter 🔤

Let's encode just the first letter of our message. 🔤

let message = 'hello'
let shift = 3
let first = String.fromCharCode(message.charCodeAt(0) + shift)
console.log('First letter becomes:', first)

Loop Over Every Letter 🔁

Now we loop through ALL letters and shift each one. 🔁

let message = 'hi'
let shift = 3
for (let i = 0; i < message.length; i++) {
  console.log(String.fromCharCode(message.charCodeAt(i) + shift))
}

Collect Into the Box 📥

Instead of printing, we add each shifted letter into our secret box! 📥

let message = 'hi'
let shift = 3
let secret = ''
for (let i = 0; i < message.length; i++) {
  secret += String.fromCharCode(message.charCodeAt(i) + shift)
}
console.log('Secret:', secret)

Encode 'hello' 🎉

Let's encode a real word and reveal the secret! 🎉

let message = 'hello'
let shift = 3
let secret = ''
for (let i = 0; i < message.length; i++) {
  secret += String.fromCharCode(message.charCodeAt(i) + shift)
}
console.log('hello becomes:', secret)

An Encode Function 🛠️

Let's make a reusable encode function for any message! 🛠️

function encode(msg, shift) {
  let out = ''
  for (let i = 0; i < msg.length; i++) {
    out += String.fromCharCode(msg.charCodeAt(i) + shift)
  }
  return out
}
console.log(encode('cat', 2))

Different Keys, Different Secrets 🗝️

Change the key and the secret changes too! Try a few. 🗝️

function encode(msg, s) {
  let out = ''
  for (let i = 0; i < msg.length; i++) out += String.fromCharCode(msg.charCodeAt(i) + s)
  return out
}
console.log(encode('dog', 1))
console.log(encode('dog', 5))

Full Encoder 🎮

Here is your complete secret message maker! 🎮🔐

function encode(msg, s) {
  let out = ''
  for (let i = 0; i < msg.length; i++) out += String.fromCharCode(msg.charCodeAt(i) + s)
  return out
}
console.log('Message: meet me at noon')
console.log('Secret:', encode('meet me at noon', 4))

Quick Check ✅

Test your encoding skills! 🧠

Code Maker! 🌟

Brilliant, agent! 🕵️ You can now encode messages! 🎉

  • Loop and shift each letter 🔁
  • Collect into a secret box 📦
  • The shift is your secret key 🗝️

Last step: decoding! 🔓

console.log('Encoding: MASTERED! 🌟')

Frequently asked questions

Is the “Encoding” lesson free?

Yes — the full text of “Encoding” 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 “Encoding”?

Text to code. 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 “Encoding” 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