Back to notes
What are the two keywords used to declare variables in JavaScript?
Press to flip
The keywords are `let` and `const`.
What is the purpose of the Live Server extension in VS Code?
The Live Server extension provides real-time updates and automatically refreshes the webpage upon saving changes, enhancing development efficiency.
Explain how to link a CSS file to an HTML document.
Link a CSS file to an HTML document using the `<link>` tag within the `<head>` section of the HTML.
How do you create a comment in JavaScript for single-line and multi-line?
For single-line comments, use `//`; for multi-line comments, use `/* */`.
How do you generate a base HTML structure in VS Code?
You generate a base HTML structure in VS Code by typing `!` followed by pressing the *Tab* key.
What is the function of the `eval()` method in JavaScript?
The `eval()` function evaluates a string as a JavaScript expression and executes the arithmetic operations contained in the string.
Describe how to display a pop-up message using JavaScript.
Use the `alert` function to display a pop-up message in the browser.
What are the three main files in a basic web project structure?
The three main files are: an HTML file (index.html) for structure, a CSS file (style.css) for styling, and a JavaScript file (index.js) for interactivity.
Where should you place `<script>` tags to link JavaScript in an HTML document and why?
Place `<script>` tags at the bottom of the HTML document body to ensure the HTML content is loaded before the JavaScript runs.
How do you output text to the browser console using JavaScript?
Use the `console.log` function to output text to the browser console, useful for debugging.
List and describe the three basic data types in JavaScript.
The three basic data types in JavaScript are: Numbers (for arithmetic), Strings (series of characters enclosed in quotes), and Booleans (`true` or `false`).
What is the purpose of event listeners in JavaScript?
Event listeners are used to execute specified JavaScript code when specific events occur (e.g., button clicks).
How do you perform addition and multiplication in JavaScript?
Use the `+` operator for addition and the `*` operator for multiplication.
How do you select an HTML element by its ID and change its text content using JavaScript?
Use `document.getElementById('elementID').textContent = 'new text';` to select the element and change its text content.
What is JavaScript and how does it enhance web pages?
JavaScript is a programming language that creates dynamic and interactive web pages by responding to user actions and processing inputs.
Previous
Next