Skip to content

fuflik007/pr3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaScript Advanced Lesson

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.

Exercises

1. Array Methods

  • Task 1.1: Create a function named filterEvenNumbers that takes an array of numbers and returns a new array containing only the even numbers. Use the filter() method.
  • Task 1.2: Create a function named doubleNumbers that takes an array of numbers and returns a new array with each number doubled. Use the map() method.
  • Task 1.3: Create a function named sumArray that takes an array of numbers and returns the sum of all numbers. Use the reduce() method.

2. Closures

  • Task 2.1: Create a function named createCounter that 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 createMultiplier that takes a number multiplier as a parameter and returns a function. The returned function should take a number and return it multiplied by the multiplier.

3. Async/Await and Promises

  • Task 3.1: Create an async function named fetchUserData that returns a Promise resolving to an object { id: 1, name: "John Doe" } after 100ms delay.
  • Task 3.2: Create an async function named processData that takes a number as a parameter, waits 50ms, then returns the number multiplied by 2.

4. Classes and OOP

  • Task 4.1: Create a class named Person with a constructor that takes name and age parameters. Add a method introduce() that returns the string "Hi, I'm [name] and I'm [age] years old.".
  • Task 4.2: Create a class named Rectangle with a constructor that takes width and height parameters. Add a method getArea() that returns the area of the rectangle.

5. Destructuring and Spread

  • Task 5.1: Create a function named getFirstAndLast that takes an array and uses destructuring to return an object with properties first and last containing the first and last elements of the array.

Getting Started

  1. Clone this repository.
  2. Open script.js and complete the tasks.
  3. Run the tests to check your progress.

Testing

Run the tests to check your progress. Each task has its own test suite.

npm install
npm test

Submission

  • Push your changes to your GitHub repository.
  • Ensure all 10 tests pass.
  • Submit the repository link to your instructor.

JS-Advanced

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors