diff --git a/curriculum/challenges/english/blocks/lecture-introduction-to-strings/672d49c4e899345f5b33c24c.md b/curriculum/challenges/english/blocks/lecture-introduction-to-strings/672d49c4e899345f5b33c24c.md index 25032ad7ae8..17ea599e25b 100644 --- a/curriculum/challenges/english/blocks/lecture-introduction-to-strings/672d49c4e899345f5b33c24c.md +++ b/curriculum/challenges/english/blocks/lecture-introduction-to-strings/672d49c4e899345f5b33c24c.md @@ -5,7 +5,9 @@ challengeType: 19 dashedName: what-is-console-log --- -# --description-- +# --interactive-- + +The prior lessons introduced you to `console.log()` but this lesson will dive deeper into its purpose and usage. In JavaScript, `console.log()` is a simple yet powerful tool used to display messages or output information to the browser's console. It's mostly used by developers to debug and inspect code while working on their programs. @@ -13,22 +15,44 @@ You can use `console.log()` to log text or variables to the console and ensure y To use `console.log()`, you call the method with the value or message you want to output inside the parentheses. Here are some examples: +:::interactive_editor + ```js console.log("Hello, world!"); let num = 5; -console.log(num); +console.log(num); // 5 ``` +::: + The first example prints `Hello, world!` in the browser's console, while the second example prints the value `5`. Here is another example of working with `console.log()`: +:::interactive_editor + ```js let name = "Alice"; -console.log("Hello, " + name + "!"); // Outputs: Hello, Alice! +console.log("Hello, " + name + "!"); // Hello, Alice! ``` +::: + +You can also pass in multiple values to `console.log()` separated by commas. For example: + +:::interactive_editor + +```js +let name = "Alice"; +let age = 25; +console.log("Name:", name, "Age:", age); // Name: Alice Age: 25 +``` + +::: + +This is helpful for logging multiple pieces of information at once. + The `console.log()` method helps you monitor your code as it runs, making it easier to spot mistakes and understand how your program behaves. # --questions-- @@ -136,7 +160,7 @@ Review the beginning of the lesson where this was discussed. --- -It is commonly used to ensure that your JavaScript code is adhering to best practices. +It is commonly used to ensure that your JavaScript code is adhering to best practices. ### --feedback--