Javascript console

Hello House,
My javascript code is not rendering on my google chrome browser.

I tried to refresh the browser but nothing is showing.

Can anyone help me out pls?


Hi @Treasure !

Screenshots are hard to read for code.

Please write your code directly into the forum.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Hi @Treasure!

For what I see you’re trying to print person in you browser’s console but you’re actually writing your code in Visual Studio Code, right?

There’re are some ways to execute the JavaScript code you’re writing.
One is using a browser, almost all browsers are bundled with JavaScript so you don’t need to make any configuration in this case. But if you want to print something in your browser’s console you need to actually write that code in the browser’s console:

Try writing your code directly in the browser’s console where you’re expecting to ‘render’ something:

let person = {
  name: 'Esther',
  age: 30
}

click enter, then:

console.log(person)

This works because you’re working on the browser’s console and it is able to execute javascript code already.

The other way to execute JS is directly in your computer but for that you need something that allows you to execute JS code outside of a web browser, and is called NodeJS. I don’t recommend going into NodeJS learning right now since it seems you’re working through the JS basics. But if what you want is to execute your programs that you’re writing in Visual Studio Code there are some ways in which you can execute a javascript file, but for what I know all of them need you to have Node installed on your computer. If that is the case try searching how to install nodejs and then I can give you some resources on how to execute that code in your computer’s console once you have it installed.

Other options are to write your JS code in some online editor and you don’t need any configuration, there are some option such as:

https://jsfiddle.net/

Hope it helps!

Based on your screenshot, it looks like you are going through a tutorial?

I know a lot of tutorials, will have you create an index.html, and index.js file and link your js file in the html file using script tags.

Here is a guide from Mosh on how to do what I was just talking about.
Setting up dev environment

Once you go through that guide then you will start to see the results.
But as of right now you are trying to open a new tab in the browser and opening up the console but that is not going to work.

Follow the guide and it should answer your question.

Thank you for the recommendations.

I will also like to have those resources on how to code outside the browser.

Thank you.

Ok, thanks for the tips.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.