16.01 · Input & output / Learn · 5 min
Follow input into output
A program can read a value, use it, and send a response. Follow each step.
Activity 1 of 7 in Input & output
JavaScript Basics / 16.01
Follow input into output
Not started
A program can read a value, use it, and send a response. Follow each step.

Input, processing, output
Input is information the program receives, such as a typed name. Processing uses that value. Output is the response, such as a greeting printed in the terminal.
A terminal and a browser are different environments. Node.js can use its built-in readline module to ask questions in a terminal. LiveCodes runs browser JavaScript and cannot use Node’s require, process.stdin or readline.
Practice the calculation separately
Here rawAge represents a value that somebody typed. It is text, even though it contains digits. Adding one to text joins characters: "18" + 1 becomes "181".
Number(rawAge) converts this known numeric text to a number, so age + 1 becomes 19. This example assumes valid numeric input; a real form also needs validation.
const rawAge = "18";
const age = Number(rawAge);
console.log(age + 1);Know what conversion accepts
Number(" 20 ") is 20; Number("hello") is NaN; Number("") is 0. Blank input therefore needs a separate check if blank means missing. Don’t assume every entered string is a valid age.
The next video uses the terminal. A browser practice afterward isolates conversion so you can test and share that part here.
Convert a supplied text reply before calculating
Work through 3 focused steps. Read the explanation, type each requested change and check it before moving on. Your own code carries forward.
The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.
Start mini-lesson(opens in a new tab)3 steps · Saved work · Instant feedback
YOUR TURN
Try the examples on this page
Choose Load this code into the editor beside an example, then edit and Run code here. Predict what will print before running it. This is an exploration workspace, so there is no pass/fail challenge. Its saved work stays separate from the next practice activity.
Load an example, edit it and run it. Word wrap is enabled.
Your check results
Work in VS Code instead
Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.
const rawAge = "18";
const age = Number(rawAge);
console.log(age + 1);Ready to try it?
Practice in your browser and see your results.
Progress details
Have a question?
Ask the Code Zone community.
Ask a question in The Code Zone (opens in a new tab)Continue learning

7 days freeTry The Code Zone
THE CODE ZONE COMMUNITY
Your next step is easier together.
Try the community free for 7 days.
No charge during your trial. Choose your plan on Skool.
- Ask questions and get support in the community
- Watch every course video walkthrough
- Find a study buddy in the 24/7 study room
Make the most of your trial with Premium.
Choose Premium on Skool to try Thursday live help sessions. Bring your questions, work through code, and get unstuck together.
Scheduled Thursdays in Eastern Time. Check the Skool calendar for your local date and time.
Have a website account? Sign in