This project contains exercises to practice advanced JavaScript concepts. Follow the instructions for each exercise precisely. The automated tests will check your work against these exact requirements.
- Task 1.1: Create a function named
filterEvenNumbersthat takes an array of numbers and returns a new array containing only the even numbers. Use thefilter()method. - Task 1.2: Create a function named
doubleNumbersthat takes an array of numbers and returns a new array with each number doubled. Use themap()method. - Task 1.3: Create a function named
sumArraythat takes an array of numbers and returns the sum of all numbers. Use thereduce()method.
- Task 2.1: Create a function named
createCounterthat returns a function. The returned function should increment and return a counter each time it's called, starting from 0. - Task 2.2: Create a function named
createMultiplierthat takes a numbermultiplieras a parameter and returns a function. The returned function should take a number and return it multiplied by themultiplier.
- Task 3.1: Create an async function named
fetchUserDatathat returns a Promise resolving to an object{ id: 1, name: "John Doe" }after 100ms delay. - Task 3.2: Create an async function named
processDatathat takes a number as a parameter, waits 50ms, then returns the number multiplied by 2.
- Task 4.1: Create a class named
Personwith a constructor that takesnameandageparameters. Add a methodintroduce()that returns the string"Hi, I'm [name] and I'm [age] years old.". - Task 4.2: Create a class named
Rectanglewith a constructor that takeswidthandheightparameters. Add a methodgetArea()that returns the area of the rectangle.
- Task 5.1: Create a function named
getFirstAndLastthat takes an array and uses destructuring to return an object with propertiesfirstandlastcontaining the first and last elements of the array.
- Clone this repository.
- Open
script.jsand complete the tasks. - Run the tests to check your progress.
Run the tests to check your progress. Each task has its own test suite.
npm install
npm test- Push your changes to your GitHub repository.
- Ensure all 10 tests pass.
- Submit the repository link to your instructor.