Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which of the following is the correct syntax for array destructuring?

View

What does the following code return?

View

What happens when you destructure an array with fewer variables than elements?

View

What does the rest operator (...) do in array destructuring?

View

What does the following code return?

View

Can you skip elements when destructuring arrays?

View

What does the following code return?

View

How do you combine two arrays into one using the spread operator?

View

What is the output of the following code?

View

What does the following code return?

View

Which of the following is the correct syntax for array destructuring?

const {a, b} = arr;
const [a, b] = arr;
const [a: b] = arr;
const (a, b) = arr;

What does the following code return?

const arr = [10, 20, 30]; const [first, second] = arr; console.log(first, second);

10 20
20 30
30 10
undefined

What happens when you destructure an array with fewer variables than elements?

The remaining elements are ignored
The code will throw an error.
All elements must be assigned
The remaining elements will be assigned to the last variable

What does the rest operator (...) do in array destructuring?

Gathers remaining array elements into a new array
Extracts elements from arrays
Combines arrays
Removes elements from arrays

What does the following code return?

const arr = [1, 2, 3, 4, 5]; const [first, ...rest] = arr; console.log(rest);

[1]
[2, 3, 4, 5]
undefined
[]

Can you skip elements when destructuring arrays?

Yes, by leaving gaps in the destructuring pattern
No, every element must be assigned
Only with the spread operator
Only with nested arrays

What does the following code return?

const arr = [1, 2, 3]; const [, second, third] = arr; console.log(second, third);

1 2
2 3
1 3
3 1

How do you combine two arrays into one using the spread operator?

const combined = [...arr1, ...arr2];
const combined = arr1.concat(arr2);
const combined = [...arr1 arr2];
Both a and b

What is the output of the following code?

const arr1 = [1, 2]; const arr2 = [3, 4]; const combined = [...arr1, ...arr2]; console.log(combined);

[1, 2, [3, 4]]
[1, 2, 3, 4]
[[1, 2], [3, 4]]
[3, 4, 1, 2]

What does the following code return?

const arr = [1, 2, 3]; const newArr = [0, ...arr, 4]; console.log(newArr);

[0, 1, 2, 3, 4]
[1, 2, 3]
[0, [1, 2, 3], 4]
undefined