Output
Part of the Fundamentals section of Coddy's JavaScript journey — lesson 28 of 77.
In programming, we often need to show information to the user. This is called output. In JavaScript, the simplest way to output something is to use console.log().
Here's how you can use it:
console.log("This is some text.");This will print This is some text. to the console.
You can output different types of data, such as numbers and booleans:
console.log(123); // Output: 123console.log(true); // Output: trueYou can also output multiple values at once by separating them with commas:
console.log("Hello", "World", "!"); // Output: Hello World !This will print each value with a space in between.
Remember, console.log() is mainly used for testing and debugging your code. It's a powerful tool to see what's happening in your program.
Challenge
BeginnerWrite a program that outputs the following lines:
Welcome to Coddy!
JavaScript is fun.Cheat sheet
To output information in JavaScript, use console.log():
console.log("This is some text.");You can output different types of data:
console.log(123); // numbers
console.log(true); // booleansOutput multiple values by separating them with commas:
console.log("Hello", "World", "!"); // Output: Hello World !Try it yourself
// Type your code belowThis lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Type Coercion7Bill Split Calculator
Welcome MessageCalculating The Tip And Total2Variables
NumbersStringBooleanNaming ConventionsEmpty VariablesRecap - Initialize VariablesConstants3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsComparison OperatorsStrict vs Loose EqualityRecap - Simple Math6Basic IO
OutputOutput with VariablesType Conversion - Part 1Type Conversion - Part 2Recap - Till 120Recap - True or False