Asking the User
Read input.
Asking the User 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.
Talk to the User! 💬
A real converter asks YOU for a temperature! Let's learn how programs get input. 💬🌡️
console.log('Let us ask for a number! 💬')What Is Input? 📥
Input is information a person gives to a program, like typing a number or a name. 📥
console.log('Input is what YOU type in!')Pretend Input 🎭
To practice, we can pretend the user typed a number by putting it in a variable. 🎭
let userTemp = 25
console.log('The user typed:', userTemp)Use the Input 🔧
Once we have the input, we can convert it! Let's turn the user's Celsius into Fahrenheit. 🔧
let userTemp = 25
let result = userTemp * 9 / 5 + 32
console.log('That is', result, 'F')Numbers vs Text 🔢
When users type, the computer often sees it as text like '25'. We turn it into a number with Number(). 🔢
let typed = '25'
let temp = Number(typed)
console.log('As a number:', temp + 5)Why Convert Text? 🤨
Look what happens if we forget! Text plus text just sticks together instead of adding. 🤨
console.log('25' + 5)
console.log(Number('25') + 5)Ask Which Scale 🔀
We can also ask which way to convert. Let's pretend the user chose 'C to F'. 🔀
let choice = 'C to F'
console.log('User wants:', choice)Input Into a Function 🛠️
We pass the user's number straight into our converter function! 🛠️
function toF(c) { return c * 9 / 5 + 32 }
let userTemp = 30
console.log(userTemp, 'C =', toF(userTemp), 'F')Check for Silly Input 🚫
What if someone types something weird? We can check if it's really a number! 🚫
let typed = 'banana'
let temp = Number(typed)
if (isNaN(temp)) {
console.log('That is not a number! 🍌')
}Friendly Prompt 😊
Before asking, show a friendly message so the user knows what to type! 😊
console.log('Please enter a temperature in Celsius: 🌡️')
let userTemp = 18
console.log('You entered:', userTemp)Full Input Demo 🎮
Here is the whole input flow: greet, read, convert! 🎮
console.log('Enter Celsius: 🌡️')
let typed = '20'
let temp = Number(typed)
let f = temp * 9 / 5 + 32
console.log(temp, 'C =', f, 'F')Quick Check ✅
Test your input knowledge! 🧠
Input Pro! 🌟
Nice work! You learned to ask the user! 🎉
- Input is what the user gives 📥
Number()turns text into numbers 🔢- Check for silly input 🚫
Last step: showing the result! 📢
console.log('Asking the user: DONE! 🌟')Frequently asked questions
Is the “Asking the User” lesson free?
Yes — the full text of “Asking the User” 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 “Asking the User”?
Read input. 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 “Asking the User” 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
- Two Temperature Scales
- The Formula
- Asking the User
- Showing the Result