0Pricing
Javascript for Kids · Lesson

Showing the Answer

Print the result.

Showing the Answer is a free Javascript for Kids lesson on CoddyKit — lesson 4 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.

Show the Answer! 📣

Our calculator can store numbers, do math, and pick an operation. The last step is showing the answer in a NICE way! ✨

Let us make it friendly and clear for everyone to read.

Save Then Show 💾

First save the answer in a box called result, then print it!

let a = 5
let b = 3
let result = a + b
console.log(result)

A Full Sentence 💬

Let us show the whole math problem AND the answer together!

let a = 5
let b = 3
let result = a + b
console.log(a + ' + ' + b + ' = ' + result)

Add Some Sparkle ✨

Make the answer exciting with emojis and words!

let a = 8
let b = 2
let result = a * b
console.log('🎉 The answer is ' + result + '! 🎉')

Show Based on Choice 🎯

Let us combine if with showing! Pick an op, compute, and display nicely.

let a = 10
let b = 5
let op = 'add'
let result = 0
if (op === 'add') {
  result = a + b
}
console.log('Result: ' + result)

The Whole Calculator! 🧮

Here is our COMPLETE calculator! It picks the math and shows a clear answer.

let a = 12
let b = 4
let op = 'multiply'
let result = 0
if (op === 'add') {
  result = a + b
} else if (op === 'subtract') {
  result = a - b
} else if (op === 'multiply') {
  result = a * b
} else if (op === 'divide') {
  result = a / b
}
console.log(a + ' ' + op + ' ' + b + ' = ' + result)

Try Multiply 🔢

Change op to 'subtract' in the full calculator and watch the answer change!

let a = 9
let b = 4
let op = 'subtract'
let result = 0
if (op === 'add') {
  result = a + b
} else if (op === 'subtract') {
  result = a - b
}
console.log('Answer: ' + result)

Handle Mistakes 🛟

If the user picks a weird op, let us show a friendly oops message instead of a wrong answer!

let op = 'jellybean'
if (op === 'add') {
  console.log('Adding!')
} else {
  console.log('Oops! Please pick add, subtract, multiply, or divide. 🙂')
}

Decorate the Output 🎀

Add lines around the answer to make it stand out like a banner!

let a = 6
let b = 6
let result = a + b
console.log('=============')
console.log('Answer: ' + result)
console.log('=============')

Round Answers 🔵

Dividing can make long decimals! Math.round makes a neat whole number.

let a = 7
let b = 2
let result = a / b
console.log('Exact: ' + result)
console.log('Rounded: ' + Math.round(result))

Your Turn: Final Calculator 🌟

Change the numbers and the op, then run YOUR own calculator! You built this! 🏆

let a = 15
let b = 3
let op = 'divide'
let result = 0
if (op === 'add') {
  result = a + b
} else if (op === 'subtract') {
  result = a - b
} else if (op === 'multiply') {
  result = a * b
} else if (op === 'divide') {
  result = a / b
}
console.log(a + ' ' + op + ' ' + b + ' = ' + result)

Quick Check ✅

Final brain check! 🧠

Calculator Complete! 🎉

YOU BUILT A CALCULATOR! 🧮🏆 Amazing work!

  • Stored two numbers in boxes
  • Did math with + - * /
  • Picked an operation with if
  • Showed the answer nicely with console.log

You are a real coder now! Show your calculator to a friend! 💛🚀

Frequently asked questions

Is the “Showing the Answer” lesson free?

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

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

How long does the “Showing the Answer” 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. Two Numbers
  2. Doing Math
  3. Picking an Operation
  4. Showing the Answer
← Back to Javascript for Kids