0% found this document useful (0 votes)
6 views2 pages

1 JavaScript in

The document outlines the role of JavaScript in web development, emphasizing its ability to add interactivity and manipulate content. It covers the basics of including JavaScript code, variable declarations, data types, and control flow with conditional statements. Additionally, it provides examples of comparing values and displaying student grade levels using JavaScript syntax.

Uploaded by

tabel5509
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

1 JavaScript in

The document outlines the role of JavaScript in web development, emphasizing its ability to add interactivity and manipulate content. It covers the basics of including JavaScript code, variable declarations, data types, and control flow with conditional statements. Additionally, it provides examples of comparing values and displaying student grade levels using JavaScript syntax.

Uploaded by

tabel5509
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

JavaScript in Web Development:

- Adds interactivity and responsiveness to web pages.


- Manipulates content, creates user interfaces, validates input, and interacts with servers.

2. Including JavaScript Code:

- Use <script> tag: <script> ... your code here ... </script>`

3. Placement:

- Body Section (<body>): Recommended for most cases to avoid rendering delays.

4. JavaScript Statements:

- Instructions for JavaScript to execute (variable declarations, function definitions, etc.).

5. Multiple Statements in a Line:

- Separate with semicolons (;).

6. Variables:

- Store data that can change. Declare with `let` (recommended) or `const`.

7. Variable Naming Rules:

- Start with letter, underscore, or dollar sign.


- Subsequent characters can be letters, numbers, or underscores.
- Case-sensitive.
- Cannot be a reserved keyword.

8. Basic Data Types:

- `number`, `string`, `boolean`, `undefined`, `null`, `object` (including arrays).

9. Objects vs. Arrays:

- Objects:Unordered key-value pairs (like dictionaries).


- Arrays: Ordered collections accessed by index (like lists).

10. Operators:
- Perform calculations, comparisons, manipulations, etc.

11. Concatenation Operator (+):

- Joins strings or numbers.

12. Conditional Statements:

- Control program flow based on conditions (e.g., `if`, `else if`, `else`).

13. if...else if Statement:

- Evaluates conditions sequentially.

14. Comparing Student Weights:

javascript
let weight1 = 70;
let weight2 = 85;

let heavier = weight1 > weight2 ? weight1 : weight2;


[Link]("Heavier student:", heavier);
```

15. Displaying Student Grade Level:

```javascript
let grade = 10;

if (grade >= 9 && grade <= 12) {


[Link]("High school student");
} else if (grade >= 5 && grade <= 8) {
[Link]("Middle school student");
} else if (grade >= 1 && grade <= 4) {
[Link]("Elementary school student");
} else {
[Link]("KG student");
}

You might also like