WEEK TWO
LESSON ONE: ARRAYS
Tasks:
Task 1: Add elements to an array
● Create an empty array and assign it to a variable.
● Use the push() method to add elements to the array.
● Log the array to the console to see the updated elements.
Task 2: Remove elements from an array
● Create an array with multiple elements.
● Use the pop() method to remove the last element from the array.
● Use the shift() method to remove the first element from the
array.
● Log the array to the console to see the updated elements.
Task 3: Modify elements in an array
● Create an array with multiple elements.
● Use array indexing to access a specific element.
● Modify the element value using assignment.
● Log the array to the console to see the updated value.
Task 4: Iterate over an array
● Create an array with multiple elements.
● Use a loop (such as for or forEach()) to iterate over the array.
● Perform an action on each element, such as logging it to the
console.
Task 5: Filter elements in an array
● Create an array with multiple elements.
● Use the filter() method to create a new array containing only
specific elements based on a condition.
● Log the filtered array to the console.
LESSON TWO: OBJECTS
Tasks:
Task 1: Create an object
● Declare an empty object and assign it to a variable.
● Add properties to the object using dot notation or bracket
notation.
● Log the object to the console to see the properties.
Task 2: Access and modify object properties
● Create an object with multiple properties.
● Use dot notation or bracket notation to access a specific
property.
● Modify the property value using assignment.
● Log the object to the console to see the updated value.
Task 3: Iterate over object properties
● Create an object with multiple properties.
● Use a loop (such as for...in) to iterate over the object
properties.
● Perform an action on each property, such as logging its key and
value to the console.
Task 4: Remove properties from an object
● Create an object with multiple properties.
● Use the delete keyword to remove a specific property from the
object.
● Log the object to the console to see the updated properties.
Task 5: Merge objects
● Create multiple objects with different properties.
● Use the Object.assign() method to merge the objects into a
single object.
● Log the merged object to the console.
Task 6: Missing parentheses
● Given the following code snippet, identify and fix the syntax
error:
if (x === 5 {
console.log("x is equal to 5");
Task: Missing semicolon
Given the following code snippet, identify and fix the syntax error:
const message = "Hello, world"
console.log(message)
Task: Incorrect closing brace placement
● Given the following code snippet, identify and fix the
syntax error:
function sayHello() {
console.log("Hello!");
}
console.log("Goodbye!");
Task: Mismatched opening and closing brackets
Given the following code snippet, identify and fix the syntax error:
const numbers = [1, 2, 3, 4, 5];
console.log(numbers[2];
Task: Incorrect function definition
Given the following code snippet, identify and fix the syntax error:
const addNumbers = function(x, y)
return x + y;
};
console.log(addNumbers(5, 10));