Console - Reading Assignment

Hi @Bette,

Q1 & 2 :ok_hand:

Question 3…

Yes…but not as HTML-formatted content. The console.log function always prints to the console (not the web page document) and so:

console.log("<h1>I'm the main title<h1>");    
/* =>  <h1>I'm the main title</h1>   logged to the console (the HTML tags
       are not interpreted as anything different than as part of the string. */

document.write("<h1>I'm the main title<h1>");
/* I'm the main title   displayed as a formatted title on the web page
  (marked up with HTML h1 element tags */

Question 4…

… and we can change the contents of an HTML page by writing JavaScript code which accesses and manipulates the page’s Document Object Model (DOM).

1 Like

Hi @jordii,

Nice answers to Q1, 2 and 4 :ok_hand:

I think you misunderstood Q3 — it’s asking about the specific purpose of the console.log() function, not what the console does in general:

The console.log() function enables information to be displayed on the screen (literally logged to the console ). The information logged is whatever value is defined within the parentheses.

1 Like

Hi @petr,

Nice answers :ok_hand:

Just to clarify Q4…

You are right that we are not making permanent changes to the document stored on the server. However, we can use the console to make temporary changes to the contents of an HTML page for testing and experimentation purposes. We can do this by writing JavaScript code which accesses and manipulates the page’s Document Object Model (DOM).

2 Likes
  1. What is the console used for? Provides you with the ability to write, manage, and monitor JavaScript on demand.
  2. How do you open the Console in Google Chrome? More tools > Developer Tools, a panel will open and you are able to select console.
  3. What does console.log function do? Allows the user to print something without needing to click out of it when it returns undefined.
  4. How can you change the contents of an HTML page through the console? You cannot permanently change the content, its a place to experiment.
1 Like
  1. The Console is used to log information which can be written ā€˜on the fly’ (eg. JavaScript expressions)

  2. The console can be opened in Chrome by clicking the ā€˜three dot’ symbol --> More Tools --> Developer Tools. Or pressing ā€˜CTRL + Shift + I’ in Windows / Linux

  3. The Console.log outputs / prints a message to the web console

  4. The HTML contents can be dynamically edited in the console by adding JavaScript code, which then temporarily alters the Document Object Model (DOM) of a page

1 Like

Thanks for the clarifications! HTML tags are not interpreted in the console and instead shown as a string. Got it. :+1:

1 Like
  1. What is the console used for?
    The console is used to write, manage and monitor JavaScript on demand.

  2. How do you open the Console in Google Chrome?
    It is virtually the same for Brave which I currently use…go to the top-right corner and select the drop-down menu signified by the 3 dots (lines in Brave) then select ā€˜More Tools’ and then ā€˜Developer Tools’. Once this window has popped up, go to the 2nd tab along which is entitled ā€˜Console’.

  3. What does console.log function do?
    The console.log function allows us to write JavaScript code straight into the console and test it out in real time.

  4. How can you change the contents of an HTML page through the console?
    You can change the contents of an HTML page (including HTML, CSS and JavaScript languages) by amending anything you like within the console. When you reload the page however, the original state of the document will be loaded, so any changes you make are not permanent.

1 Like

Correct!

But you can still write this in the console:

and it will then display as a formatted title, I’m the main title , on the web page. It just won’t be logged like that in the console itself if you use console.log() i.e.

This will log  <h1>I'm the main title<h1>  to the console with no formatting (obviously).

Have a play around and experiment yourself with it in the console. That’s the best way to get things like this clear in your own mind :slight_smile:

1 Like

1.The console is a way to interact with a webpage/browser using JavaScript. It is a bit like the terminal in Linux or CMD in Windows. Instead of writing a program script with atom or sublime text, you code interactively (or ā€œliveā€). I kinda consider it to be a bit like ā€œspeakingā€ JavaScript.
2.I personally right-click and select ā€œinspectā€ and then i can select the console tab in the new pane to the right.
3.It prints a message that needs to be displayed to the user, for example it can return the value of any parameter or variable that is given to it. Or to just display a message of some sort.
4.You can modify it by learning some Javascript and some basic HTML and how the two interacts. This goes beyond my abilities at the moment though, i have tried it but just barely.

1 Like
  1. What is the console used for?
    Can be used to log info as part of the development process. Interact with a web page by carrying out JS expressions. Write, manage ans monitor JS on demand.

  2. How do you open the Console in Google Chrome?
    Top right menu, select more tools then select developer tools. A panel will open click console

  3. What does console.log function do?
    As opposed to alert(), the console.log() allows output to be displayed on the console.

  4. How can you change the contents of an HTML page through the console?
    Load the html file onto the browser. Open console to work with JS on the page. Any changes will be lost with refresh so save the changes.

1 Like

1. What is the console used for?
-Console allow you to write,manage or monitor JavaScript on demand
2. How do you open the Console in Google Chrome?
-go to more tools and open developer tools
3. What does console.log function do?
-print out the output in console
4. How can you change the contents of an HTML page through the console?
-go to the element and modify the DOM

1 Like

What is the console used for?
-the Console provides you with the ability to write, manage, and monitor JavaScript on demand.

How do you open the Console in Google Chrome?
-In the menu under more tools,then developer tools.

What does console.log function do?
-The JavaScript Console provides you with a space to try out JavaScript code in real time by letting you use an environment similar to a terminal shell interface.

How can you change the contents of an HTML page through the console?
-You can experiment with modifying HTML through the console,but you are not changing the HTML document.

1 Like
  1. The console is a basic computer or monitor and keyboard that is connected to another computer, server or a mainframe over a network.

  2. to view logged messages or run JavaScript. Press, Control + Shift + i to jump straight into the Console panel.

  3. logs info to the javascript console.

  4. double-click a selected element and make changes

1 Like
  • What is the console used for?
    to play with javascript on a page

  • How do you open the Console in Google Chrome?
    go to developer tools in the menu

  • What does console.log function do?
    output the result of javascript code to the console

  • How can you change the contents of an HTML page through the console?
    by addressing elements via javascript.

1 Like
  1. The console provides us with the ability to write, manage, and monitor JavaScript on demand.
  2. The console in Google console is opened by below shortcut keyboard.
    CTRL + SHIFT + J (Linux or Windows)
    COMMAND + OPTION + J (macOS)
  3. It logs the information in the Javascript console and shows the output inside the console.
  4. We can use Javascript to modify html code on the HTML page.
1 Like
  • What is the console used for?
    Console is use for java script development and on page java script interaction
  • How do you open the Console in Google Chrome?
    Control + shift + J
  • What does console.log function do?
    It prevents the command to show on the page, so you can work on your script without distraction.
  • How can you change the contents of an HTML page through the console?
    right click the page and go to inspect, you can change the HTML on ELEMENT
1 Like
  1. The Console is used to log information as part of the Javascript process, interact with the elements of the webpage and execute the commands by carrying out the Javascript expressions.

  2. You open the Console in google chrome by Control+Shift+I (Mac)

  3. The 'console.log" function logs a value output so you can carry out maths calculations.

  4. You can change the contents of an HTML page through the Console by using the element or inspector tab inside the Console. Save the html file (from Atom for example) and open it in a browser and then the element/inspector tab inside the Console.

1 Like
  1. What is the console used for?
    It provides the programmer with the ability to write, manage and monitor Javascript.

  2. How do you open the Console in Google Chrome?
    Activation of the console is located within the developers menu, and depending on the type of browser and computer might be slightly different to engage. Shortcuts for activation normally are:
    -macOS: command+option+K (Firefox) command+option+J (google chrome, brave)
    -windows/Linux: Ctrl+shift+K (Firefox), Ctrl+shift+J (chrome)

  3. What does console.log function do?
    It logs the results of the javascript commands to the console

  4. How can you change the contents of an HTML page through the console?
    I can modify the HTML page with Javascript commands. Reloading the HTML page will remove the Javascript modifications.

1 Like
  1. For displaying data in different ways
  2. Ctrl+Shift+I
  3. Writes messages to the console (display of sentences, date and time, math calculations)
  4. By opening console and working with different elements to modify html page
1 Like

Hi @Anna,

Q2 & 3 :+1:

Your answers to Q1 & 4 are OK, but we need to be more specific and add some key details:

The console is used by web developers to test and experiment with JavaScript in the context of a particular web page. New code, or modifications to the existing code, is written in the console, and can then be immediately run in the browser in order to see its effect on the web page, and also to log outputs to the console.

Yes… and we do this by writing JavaScript code which accesses and manipulates the page’s Document Object Model (DOM).

1 Like