The Formula
Convert between them.
The Formula is a free Javascript for Kids lesson on CoddyKit — lesson 2 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.
The Magic Formula! ✨
Now we learn the secret math to turn Celsius into Fahrenheit and back! ✨🌡️
console.log('Time for the temperature formula! ✨')Celsius to Fahrenheit 🔥
The formula is: F = C * 9 / 5 + 32. Let's try it with 0 Celsius! 🔥
let celsius = 0
let fahrenheit = celsius * 9 / 5 + 32
console.log(celsius, 'C is', fahrenheit, 'F')Try 100 Celsius 🌡️
Let's check our formula with boiling water at 100°C. It should give 212°F! 🔥
let celsius = 100
let fahrenheit = celsius * 9 / 5 + 32
console.log(celsius, 'C is', fahrenheit, 'F')Step by Step 👣
The formula does three things: times 9, divide by 5, then add 32. 👣
let celsius = 20
let step1 = celsius * 9
let step2 = step1 / 5
let fahrenheit = step2 + 32
console.log('Answer:', fahrenheit)Fahrenheit to Celsius ❄️
To go the other way: C = (F - 32) * 5 / 9. Let's try 32°F! ❄️
let fahrenheit = 32
let celsius = (fahrenheit - 32) * 5 / 9
console.log(fahrenheit, 'F is', celsius, 'C')Try 212 Fahrenheit 🔥
Boiling water is 212°F. Our formula should give 100°C! 🔥
let fahrenheit = 212
let celsius = (fahrenheit - 32) * 5 / 9
console.log(fahrenheit, 'F is', celsius, 'C')Brackets Matter! 🧮
The ( ) brackets tell the computer to do F - 32 FIRST. Order matters in math! 🧮
let fahrenheit = 50
let celsius = (fahrenheit - 32) * 5 / 9
console.log('Without brackets it would be wrong!')
console.log('Correct answer:', celsius)A Converter Function 🛠️
Let's wrap the formula in a reusable function! 🛠️
function toF(c) {
return c * 9 / 5 + 32
}
console.log('25 C is', toF(25), 'F')Both Directions 🔄
We can make two functions, one for each direction! 🔄
function toF(c) { return c * 9 / 5 + 32 }
function toC(f) { return (f - 32) * 5 / 9 }
console.log('10 C =', toF(10), 'F')
console.log('50 F =', toC(50), 'C')Round It Nicely 🎯
Sometimes we get long decimals. Math.round() makes a clean number! 🎯
let celsius = (98 - 32) * 5 / 9
console.log('Messy:', celsius)
console.log('Clean:', Math.round(celsius))Full Formula Demo 🎮
Here is both conversions working together, nice and clean! 🎮
function toF(c) { return Math.round(c * 9 / 5 + 32) }
function toC(f) { return Math.round((f - 32) * 5 / 9) }
console.log('30 C =', toF(30), 'F')
console.log('86 F =', toC(86), 'C')Quick Check ✅
Test your formula skills! 🧠
Formula Master! 🌟
Awesome! You learned the conversion formula! 🎉
- C to F:
c * 9 / 5 + 32🔥 - F to C:
(f - 32) * 5 / 9❄️
Next: asking the user for a temperature! 💬
console.log('The formula: MASTERED! 🌟')Frequently asked questions
Is the “The Formula” lesson free?
Yes — the full text of “The Formula” 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 “The Formula”?
Convert between them. 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 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The Formula” 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.