0230115
1. What is the difference between a parameter and a variable in programming?
2. Can you explain the concept of recursion in programming? Provide an example of a recursive function.
3. What is the difference between a stack and a queue?
4. What is the difference between an algorithm and a data structure?
5. Can you explain the concept of Big O notation and its importance in algorithm analysis?
6. What is the difference between a synchronous and an asynchronous function in JavaScript?
7. Can you provide an example of a JavaScript code snippet that demonstrates the usage of the `map()` method?
8. What is the purpose of the `reduce()` method in JavaScript?
9. Can you explain the concept of closures in JavaScript?
10. What is the difference between a prototype-based inheritance and class-based inheritance in JavaScript? Please provide an example for each.
11. Can you provide an example of a JavaScript code snippet that demonstrates the usage of the `filter()` method?
12. What is the difference between a variable and a constant in JavaScript?
13. Can you provide an example of a JavaScript code snippet that demonstrates the usage of the `for` loop?
14. What is the purpose of the `sort()` method in JavaScript?
15. Can you explain the concept of a function in JavaScript and provide an example?
16. What is the difference between a `for` loop and a `while` loop in JavaScript? Please provide an example for each.
17. Can you provide an example of a JavaScript code snippet that demonstrates the usage of the `forEach()` method?
18. What is the purpose of the `includes()` method in JavaScript?
19. Can you explain the concept of a prototype in JavaScript and how it is used in inheritance?
20. What is the difference between a synchronous and an asynchronous function in JavaScript? Please provide an example for each.

1. In programming, a parameter is a variable that is used to pass data or values to a function, method, or constructor. It represents the data that is expected to be provided when the function is called. A variable, on the other hand, is a named location in memory where data can be stored and manipulated. It can hold a value that can be changed during the execution of the program.

2. Recursion is a method where a function calls itself to solve a problem by breaking it down into smaller and smaller sub-problems until it reaches a base case. The base case is the condition where the problem is simple enough to be solved directly without further recursion. The recursion stops when the base case is reached.

Here’s an example of a recursive function to compute the factorial of a number:

```javascript
function factorial(n) {
if (n === 0 || n === 1) {
return 1;
} else {
return n * factorial(n - 1);
}
}

console.log(factorial(5)); // Output: 120
```

3. A stack is a data structure that follows the Last-In-First-Out (LIFO) principle, meaning the last element added is the first one to be removed. A queue, on the other hand, follows the First-In-First-Out (FIFO) principle, where the first element added is the first one to be removed.

4. An algorithm is a step-by-step procedure for solving a problem, while a data structure is a way of organizing and storing data in a computer so that it can be accessed and modified efficiently. Algorithms provide a logical sequence of steps for processing data, whereas data structures define how data is organized and accessed.

5. Big O notation is a mathematical notation used to describe the time complexity of an algorithm. It provides an upper bound on the growth rate of the algorithm's time or space requirements as the input size increases. Big O notation helps in analyzing and comparing the efficiency of different algorithms.

6. In JavaScript, a synchronous function executes in the order in which it is called, and the main thread of execution waits until the function finishes executing before it can continue. In contrast, an asynchronous function does not block the main thread; it allows other tasks to run while waiting for an event to complete (e.g., network response, file read/write).

7. The `map()` method in JavaScript is used to transform each element of an array and return a new array with the transformed elements. Here’s an example of using `map()` to double each element in an array:

```javascript
const numbers = [1, 2, 3, 4, 5];
const doubledNumbers = numbers.map(num => num * 2);
console.log(doubledNumbers); // Output: [2, 4, 6, 8, 10]
```

8. The `reduce()` method in JavaScript is used to apply a function to an array of values to reduce them to a single value. It takes a callback function that is called with the accumulator (initially the first element of the array) and the current element of the array. Here’s an example of using `reduce()` to sum an array of numbers:

```javascript
const numbers = [1, 2, 3, 4, 5];
const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0);
console.log(sum); // Output: 15
```

9. Closures in JavaScript are functions that have access to the variables in their own scope, even if the function is defined outside that scope. A closure is created when a function is defined inside another function and retains access to the outer function’s variables, even after the outer function has finished executing