Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7776273
Add Example.html with cookie handling functionality and Bootstrap sty…
Pankaj-Str May 17, 2025
ff17e9a
Add Basic.html and Variable.html with initial JavaScript examples and…
Pankaj-Str May 19, 2025
e591a11
Add Operator.html with examples of arithmetic, assignment, comparison…
Pankaj-Str May 19, 2025
00d8d25
Add if_else.html with user input for number comparison and result dis…
Pankaj-Str May 20, 2025
a18a906
Add Login.html and Welcome.html with login form and success message f…
Pankaj-Str May 21, 2025
7b772b4
Add Loop.html with interactive loop functionality and styled output
Pankaj-Str May 22, 2025
f7015a4
Refactor loop structure in Loop.html for improved readability
Pankaj-Str May 22, 2025
2856e12
Enhance Employee Salary Management System and Student Marksheet Appli…
Pankaj-Str May 28, 2025
f624320
Add function.html with examples of basic functions, parameters, retur…
Pankaj-Str May 28, 2025
13dc0c9
Add Global and Local Scope example HTML file with JavaScript code
Pankaj-Str May 29, 2025
8e61492
Add JavaScript Objects example and corresponding HTML file
Pankaj-Str May 29, 2025
3ddd3c3
Add String methods example with replace functionality in HTML
Pankaj-Str May 30, 2025
d512bc5
Remove outdated HTML and JavaScript files related to basic programmin…
Pankaj-Str May 31, 2025
e077d1d
Add new HTML files for basic programming concepts, including variable…
Pankaj-Str May 31, 2025
2d9c73b
Comment out unused height variable in Variable.html for clarity
Pankaj-Str May 31, 2025
7476340
Add Array.html file with examples of array and object iteration in Ja…
Pankaj-Str May 31, 2025
7c5afb6
Add examples of array mapping and finding even numbers in Array.html
Pankaj-Str Jun 3, 2025
7c7dd7a
Update 01. JavaScript Introduction.md
Pankaj-Str Jun 4, 2025
d626a49
Add Operator.html file with examples of arithmetic and logical operat…
Pankaj-Str Jun 5, 2025
b477f7d
Add initial content to 01 Variable.md
Pankaj-Str Jun 7, 2025
9b7f030
Add Event.html and Functions.js for basic arithmetic operations
Pankaj-Str Jun 17, 2025
6db7bb3
Add Error.html, Login.html, Welcome.html, and logic.js for user authe…
Pankaj-Str Jun 21, 2025
81abab1
Add Cookies.html for cookie management functionality
Pankaj-Str Jun 24, 2025
15f937f
Add Number.html and String.html with examples of math and string func…
Pankaj-Str Jun 28, 2025
90439e5
Add Regex.html with examples of regular expressions and their methods…
Pankaj-Str Jul 1, 2025
f865c26
Add Error_Exception.html to demonstrate error handling in JavaScript …
Pankaj-Str Jul 1, 2025
6fc777d
Add baisc.js and test.js with initial console log for website welcome…
Pankaj-Str Jul 3, 2025
f2d56e7
Add index.html with embedded content including Google Maps, Python tu…
Pankaj-Str Jul 3, 2025
f5617bb
update code
Pankaj-Str Jul 21, 2025
9ababad
update all codes
Pankaj-Str Oct 11, 2025
cfeb94f
Add Operator.html and Operator_js.js with arithmetic, comparison, and…
Pankaj-Str Oct 25, 2025
7a12a21
update - new codes if else
Pankaj-Str Nov 8, 2025
284febc
update if else
Pankaj-Str Nov 14, 2025
85a4e22
update Operator
Pankaj-Str Nov 15, 2025
449782b
update new if _else..
Pankaj-Str Nov 18, 2025
0af187b
Add Home.html and login.html with basic structure and functionality; …
Pankaj-Str Nov 22, 2025
62cbb40
Refactor printbill function to improve GST calculation and add quanti…
Pankaj-Str Nov 22, 2025
29522ab
Add Switch.html for basic calculator functionality with operator sele…
Pankaj-Str Nov 27, 2025
d18d338
Change button type to prevent form submission in Switch.html
Pankaj-Str Nov 27, 2025
c2df0b1
loop example
Pankaj-Str Dec 4, 2025
3ac9b43
update loop example
Pankaj-Str Dec 13, 2025
7399562
update loop
Pankaj-Str Dec 13, 2025
b5de05b
update ..login logic...
Pankaj-Str Dec 16, 2025
dc85c50
Add Example01 and Example02 HTML files for break and continue tutorial
Pankaj-Str Dec 23, 2025
b1c2bbe
Refactor Example02.html to enhance functionality and improve structur…
Pankaj-Str Dec 23, 2025
5d8ef98
Add HTML files for break, function, and index tutorials
Pankaj-Str Dec 25, 2025
b309ad3
update .. function
Pankaj-Str Jan 6, 2026
a1745dd
objects ... update
Pankaj-Str Jan 8, 2026
b95fcc0
Add String Methods tutorial HTML file with various string operations
Pankaj-Str Jan 20, 2026
55be9cf
Add index.html for full name display tutorial with input fields and f…
Pankaj-Str Jan 22, 2026
2cf8f28
Add Object, Scope, and Class tutorials with examples and method imple…
Pankaj-Str Jan 24, 2026
01c2af0
Add Array and Array User Input HTML files with examples for array man…
Pankaj-Str Jan 27, 2026
ba6334c
update new array _string
Pankaj-Str Feb 28, 2026
11a635e
for...in and for...of Loop
Pankaj-Str Mar 5, 2026
eddb144
update
Pankaj-Str Mar 5, 2026
1979df5
update codes ...
Pankaj-Str Mar 7, 2026
772d41a
update JavaScript Basic
Pankaj-Str Mar 17, 2026
67943dc
update new codes in JS
Pankaj-Str Mar 19, 2026
bd7f235
input section
Pankaj-Str Mar 24, 2026
0db5cc3
mcq codes
Pankaj-Str Mar 26, 2026
d2292e9
add Loop.html and print_box.html for JavaScript looping examples
Pankaj-Str Mar 31, 2026
489ba2c
add print_box.html for displaying a range of numbers in a styled list
Pankaj-Str Apr 2, 2026
273b203
add for_in_loop.html and for_of_loop.html for demonstrating JavaScrip…
Pankaj-Str Apr 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
178 changes: 130 additions & 48 deletions 01. JavaScript Introduction.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,132 @@
# 1- Getting Started With JavaScript
***
JavaScript is not something you need to install separately like a software program; it's already built into modern web browsers. To create and run a basic JavaScript program, you only need a text editor and a web browser. Here's a simple guide to creating your first JavaScript program:

1. **Text Editor:**
Choose a text editor to write your JavaScript code. You can use popular text editors like Visual Studio Code, Sublime Text, Atom, Notepad++, or even a plain text editor like Notepad on Windows or TextEdit on macOS.

2. **Create an HTML File:**
Create an HTML file where you'll include your JavaScript code. You can do this by opening your text editor and creating a new file with a ".html" extension. For example, you can name it `index.html`.

3. **Write the HTML Structure:**
In your `index.html` file, write the basic structure of an HTML document, including an opening and closing `<html>`, `<head>`, and `<body>` tags. Here's a simple example:

```html
<!DOCTYPE html>
<html>
<head>
<title>My First JavaScript Program</title>
</head>
<body>
<!-- Your JavaScript code will go here -->
</body>
</html>
```

4. **Adding JavaScript Code:**
Inside the `<body>` section of your HTML file, you can include JavaScript code within `<script>` tags. You can place the `<script>` tags in the `<head>` or at the end of the `<body>` section. Here's an example of adding a basic JavaScript program that displays a message:

```html
<!DOCTYPE html>
<html>
<head>
<title>My First JavaScript Program</title>
</head>
<body>
<script>
// Your JavaScript code goes here
alert('Hello, JavaScript!');
</script>
</body>
</html>
```

5. **Save the File:**
Save your `index.html` file after adding the JavaScript code.

6. **Open in a Web Browser:**
Locate your `index.html` file and open it with your preferred web browser (e.g., Google Chrome, Mozilla Firefox, or Microsoft Edge). You should see an alert message saying "Hello, JavaScript!"

That's it! You've created and executed a basic JavaScript program in an HTML document. As you continue to learn JavaScript, you can add more complex code and interact with the HTML document's content and structure. You can also link external JavaScript files and build interactive web applications as you become more proficient.
# : Running Your First "Hello, World!" Program

This tutorial walks you through creating and running a "Hello, World!" program in JavaScript, designed for absolute beginners. We’ll cover two methods: running JavaScript in a web browser and using Node.js. Each step is detailed to ensure clarity.

## What is JavaScript?
JavaScript is a programming language used to make websites interactive. It runs in browsers (e.g., Chrome) and can also work outside browsers with Node.js. This tutorial focuses on writing and running a simple program that outputs "Hello, World!".

## Prerequisites
- A computer with a web browser (e.g., Google Chrome).
- A text editor (Notepad is fine, but Visual Studio Code is recommended—free at [code.visualstudio.com](https://code.visualstudio.com/)).
- Optional: Node.js (we’ll guide you through installation for Method 2).
- No coding experience needed.

## Method 1: Running "Hello, World!" in a Web Browser
This method uses a browser to run JavaScript, displaying the output in the browser’s console.

### Step 1: Create a New File
1. Open your text editor (e.g., Notepad or VS Code).
2. Create a new file and name it `index.html`. Save it in a folder, like `C:\Users\YourName\Documents\JS_Tutorial`.

### Step 2: Write the HTML and JavaScript Code
1. Copy and paste the following code into `index.html`:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My First JavaScript Program</title>
</head>
<body>
<h1>Hello, World! Program</h1>
<script>
console.log("Hello, World!");
</script>
</body>
</html>
```
2. Save the file (`Ctrl+S` or `File > Save`).

**What’s happening here?**
- `<!DOCTYPE html>`: Declares the file as HTML.
- `<script>`: Contains JavaScript code.
- `console.log("Hello, World!");`: Prints "Hello, World!" to the browser’s console.

### Step 3: Open the File in a Browser
1. Navigate to your folder (e.g., `C:\Users\YourName\Documents\JS_Tutorial`).
2. Double-click `index.html` to open it in your default browser, or drag the file into an open browser window (e.g., Chrome).
3. The browser will display a page with the heading "Hello, World! Program".

### Step 4: View the Output in the Console
1. Open the browser’s Developer Tools:
- On Chrome: Right-click the page, select **Inspect**, or press `Ctrl+Shift+I` (Windows) or `Cmd+Option+I` (Mac).
- Go to the **Console** tab.
2. You should see "Hello, World!" in the console.
3. If you don’t see it, check for typos in the code or ensure the file was saved.

### Step 5 (Optional): Display Output on the Web Page
1. To show "Hello, World!" directly on the page, modify the `<script>` section in `index.html`:
```html
<script>
document.write("Hello, World!");
</script>
```
2. Save the file and refresh the browser (`F5` or `Ctrl+R`).
3. The text "Hello, World!" will appear on the web page below the heading.

## Method 2: Running "Hello, World!" with Node.js
This method runs JavaScript outside a browser using Node.js, displaying output in a terminal.

### Step 1: Install Node.js
1. Visit [nodejs.org](https://nodejs.org/) and download the "LTS" version (e.g., 20.17.0 as of now).
2. Run the installer and follow the prompts (accept defaults).
3. Verify installation:
- Open a terminal:
- Windows: Press `Win+R`, type `cmd`, and press Enter.
- Mac: Open Terminal from Applications > Utilities.
- Linux: Open your terminal app.
- Type `node -v` and press Enter.
- You should see a version number (e.g., `v20.17.0`). If not, reinstall Node.js.

### Step 2: Create a JavaScript File
1. Open your text editor and create a new file named `hello.js`.
2. Add the following code:
```javascript
console.log("Hello, World!");
```
3. Save the file in your folder (e.g., `C:\Users\YourName\Documents\JS_Tutorial`).

### Step 3: Run the Program
1. Open a terminal and navigate to your folder:
- Type `cd C:\Users\YourName\Documents\JS_Tutorial` (adjust the path as needed) and press Enter.
- Verify you’re in the right folder by typing `dir` (Windows) or `ls` (Mac/Linux) to see `hello.js`.
2. Run the program:
- Type `node hello.js` and press Enter.
- You should see "Hello, World!" printed in the terminal.

## Troubleshooting
- **Browser Console Empty**:
- Ensure the `<script>` tag is correct and the file is saved.
- Reload the page (`F5`) and check the Console tab.
- **Node.js Error: "node is not recognized"**:
- Reinstall Node.js and ensure it’s added to your system’s PATH.
- Restart your terminal or computer.
- **File Not Found**:
- Check that `hello.js` is in the folder and the terminal is in the correct directory (`dir` or `ls` to confirm).
- **Typos**:
- JavaScript is case-sensitive. Ensure `console.log` is written exactly as shown.

## Experiment
- Change the message in `console.log("Hello, World!");` to something like `console.log("Hi, I’m learning JavaScript!");` and rerun.
- In the browser, try `alert("Hello, World!");` to show a pop-up (replace `console.log`).
- Add multiple lines, like:
```javascript
console.log("Hello, World!");
console.log("This is my first program!");
```

## What You’ve Learned
- How to write a simple JavaScript program.
- Two ways to run JavaScript: in a browser (via HTML) and with Node.js (via terminal).
- How to use `console.log()` to display output.
- Basic debugging (checking for typos, verifying file paths).

## Next Steps
- Explore variables: `let message = "Hello, World!"; console.log(message);`
- Learn basic operators (e.g., `+`, `-`) and functions.
- Check out free resources:
- [MDN JavaScript Guide](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide)
- [W3Schools JavaScript Tutorial](https://www.w3schools.com/js/)

Loading