25 Mins beginner
4. Input & Output
I/O
Input & Output
Programs need to communicate with developers and users. In JavaScript, we have different tools depending on whether we are debugging or interacting with a web page.
๐ The Developer Console
The console.log() function is a developer's best friend. It prints data silently to the browser's developer tools or the Node.js terminal. Users never see it.
const systemStatus = "Online";
const activeUsers = 42;
console.log("System is currently:", systemStatus);
console.error("This is how you log a red error.");
console.warn("This is a yellow warning.");
OutputSystem is currently: Online
This is how you log a red error.
This is a yellow warning.
This is how you log a red error.
This is a yellow warning.
๐ฌ Browser Alerts & Prompts
In a web browser environment, you can use built-in popups to interrupt the user. Note: These functions only exist in the browser, not in Node.js or simulated environments.
// Shows a simple OK button popup
// alert("Welcome to the application!");
// Asks the user to type something
// const name = prompt("What is your name?");
// console.log("User entered:", name);
Knowledge Check
Ready to test your understanding of 4. Input & Output?