Basics JS XCERCISES - Setup and exercises

Hi! in this moments im in the beginning of 17 JS exercises for beginners and im really triying to show on my editor the code that im making on VSCode. Can you help me to see what im doing on live?

Thx in advance

Check out the Quokka extension. It is very handy for small exercises, challenges and just playing around with code. You will be limited to NodeJS so no browser API or DOM stuff. It does have a Browser-like Runtime but I don’t really use that.

Otherwise, make sure you have named your files correctly and they are inside a folder. Create a folder, inside it create an index.html file and link to your JS file using a script element or just write the JS inside the element. If you are using Live Server make sure you have opened the folder in VS Code and are starting Live Server from inside the folder you created.

1 Like

Thank you very much! It has been very helpful :smiley:.
Casually, im in the middle of a couple of “begginer’s” exercises¡in the middle of a couple of beginner exercises in which each one gives me the same answer “is not defined”. I know it may seem counterproductive to touch this little detail that I deal with but I would like to know if you could help me to know:
1-why does it say “not be defined”
2-How can I define it ".


alert is a browser-specific function that you do not have access to when using Quokka. You can only use plain JS code that will run in NodeJS. Anything browser-specific will not work. If you need access to the browser APIs you will have to run the code in the browser.

Ok! but should i use that code in browser through some tool or platform? I mean, using the DevTools of Chrome?

How i can do that? Can u redirect me to some page that can help me with that?

Or at least, how can i use prompt in VSCode so let me run the code normally because in the end: the code is well written, this problem is more a matter of platforms.

You have to run the code in the browser if you want access to the browser APIs.

  1. Create a folder, open the folder in VS Code.

  2. Inside the folder create an index.html file and a main.js file.

  3. Select the HTML file and type ! then press Enter to create the HTML boilerplate.

  4. Link to the main.js file in the HTML using a script element. Put it at the bottom before the end </body> tag.

Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script src="main.js"></script>
</body>
</html>
  1. Install the Five Server extension in VS Code. After it is installed right-click the index.html file and select “Open with Five Server”. Any code inside main.js will run. If you need to see any console logs, press F12 in the browser and look at the Console tab.
1 Like

Thank you very much! now i can see it clearly :smiley:

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