{"courses":[{"title":"JavaScript for Beginners","description":"Learn JavaScript from scratch","modules":[{"name":"Module 1: Basics","lessons":[{"name":"Module 1 Lesson 1 - Hello World","text":"

Introduction to JavaScript

\n

Welcome to the first lesson of our JavaScript for Beginners course! In this lesson, you'll learn how to write and run your first JavaScript program. We will start with the classic \"Hello World\" example, a tradition in programming to introduce the basics of any new language.

\n\n

Creating the HTML File

\n

Create a new file in your project folder and name it index.html.

\n

In the index.html file, add the following HTML code:

\n
\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Hello World</title>\n</head>\n<body>\n  <h1>Hello World</h1>\n  <script src=\"script.js\"></script>\n</body>\n</html>\n
\n

If you're brand new to programming this might look confusing, but don't worry we don't need to understand this code just yet. The only important part is <script src=\"script.js\"></script> which imports and runs our Javascipt code file.

\n\n

Writing Your First JavaScript Code

\n

Next, create a new file in the same folder and name it script.js. In this file, add the following JavaScript code:

\n
\nconsole.log('Hello, World!');\n
\n

This code uses the console.log function to print the message \"Hello, World!\" to the browser's console.

\n\n

Running Your Code

\n

To run your code you need to install the Live Server extension. This is a free VSCode extension that helps serve your code files to a web browser.

\n

In this context the term \"serve\" just means to open our code files in your web browser such as Google Chrome or Fire Fox.

\n

To install the extension simply click on the link above and click on the \"Install\" button.

\n

After the extension is installed, right-click on the index.html file in VSCode and select Open with Live Server. If you don't see that option then try restarting VSCode.

\n

After the web page opens in your browser, open the browser's console to see the \"Hello, World!\" message. You can open the console by pressing Ctrl+Shift+I (Windows) or Cmd+Option+I (Mac) and selecting the \"Console\" tab near the top.

\n\n

Understanding the Code

\n

Let's break down what we've done so far:

\n\n\n

Next Steps

\n

Congratulations! You've written and run your first JavaScript program. In the next lesson, we will delve into variables and learn how to store and manipulate data in JavaScript.

\n\n

Interactive Exercise

\n

Try modifying the message in script.js to display your name:

\n
\nconsole.log('Hello, [Your Name]!');\n
\n

Save the file and refresh your browser to see the updated message.

"},{"name":"Module 1 Lesson 2 - Variables","text":"

Understanding Variables in JavaScript

\n

Welcome to the second lesson of our JavaScript for Beginners course! In this lesson, you'll learn about variables in JavaScript. Variables are fundamental to programming as they allow us to store and manipulate data.

\n\n

What is a Variable?

\n

A variable is like a container that holds a value. You can think of it as a labeled box where you can store information and then use or change that information later in your code.

\n

In JavaScript, we can create variables using the keywords var, let, and const. For now, we'll focus on let and const, as they are more commonly used in modern JavaScript.

\n\n

Creating Variables with let and const

\n

Let's create a new file named variables.js in the same folder as your previous files. In this file, add the following JavaScript code:

\n
\nlet greeting = 'Hello, World!';\nconst pi = 3.14159;\n\nconsole.log(greeting);\nconsole.log('The value of pi is: ' + pi);\n
\n

In this example:

\n\n\n

Running Your Code

\n

To run this new JavaScript file, you need to update your index.html file to include variables.js instead of script.js. Update the index.html file as follows:

\n
\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"UTF-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n  <title>Hello World</title>\n</head>\n<body>\n  <h1>Hello World</h1>\n  <script src=\"variables.js\"></script>\n</body>\n</html>\n
\n

After updating the index.html file, open it with Live Server just like in the previous lesson. Open the browser console to see the output of your code.

\n\n

Understanding the Code

\n

Let's break down what we've done so far:

\n\n

The console.log statements print the values of these variables to the console, allowing us to see their values.

\n\n

Modifying Variables

\n

Variables declared with let can be changed. Let's modify the greeting variable:

\n
\nlet greeting = 'Hello, World!';\ngreeting = 'Hello, JavaScript!';\nconsole.log(greeting);\n
\n

In this example, we first assign 'Hello, World!' to greeting and then change its value to 'Hello, JavaScript!'. When you run this code, the console will display the updated message.

\n\n

Next Steps

\n

Great job! You've learned how to create and use variables in JavaScript. In the next lesson, we will explore different data types that you can store in variables, such as numbers, strings, and booleans.

\n\n

Interactive Exercise

\n

Try creating a new variable to store your age and print it to the console:

\n
\nlet age = 25;\nconsole.log('My age is: ' + age);\n
\n

Save the file and refresh your browser to see the updated message.

\n"}]}]}]}