ES6 - Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

Как понять это задание?

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line
  const arr = list; // Change this line
  // Only change code above this line
  return arr;
}
const arr = removeFirstTwo(source);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.124 YaBrowser/22.9.4.863 Yowser/2.5 Safari/537.36

Challenge: ES6 - Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Link to the challenge:

const source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
function removeFirstTwo(list) {
  "use strict";
  // change code below this line
  const [a, b, ...arr] = list;
  // change code above this line
  return arr;
}
const arr = removeFirstTwo(source);
console.log(arr); // should be [3,4,5,6,7,8,9,10]
console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];

как такой код может написать новичек?это вообще что?

Please use the Ask For Help button.

Stop looking up the solutions before you solve the challenge.

Copying answers makes it harder and harder for you to do anything at all without copying.

There are no examples for you to copy for the certification projects.

The given example is


const [a, b, ...arr] = [1, 2, 3, 4, 5, 7];

The solution is very similar to the example.

Я не понимаю вопроса, и не понимаю теперь ответов почему в const source = [1,2,3,4,5,6,7,8,9,10]; надо писать const{a,b, …arr}= list; а не const{a,b, …arr}= source;?

When you don’t understand the question, you should ask questions about it. You should not copy the answer.

You should not reference a global variable when you have a function argument. If you use source, then your function only works for that one array instead of any array list

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line 
  const{a,b, ...arr}= list;
  const arr = list; // Chan ge this line
  // Only change code above this line
  return arr;
}
const arr = removeFirstTwo(source);

не работает почему?

This is not array destructuring

Note: the more words you say, the easier it is for translation software to give me enough information.

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line 
  const[a, b, ...arr]= list;
   // Chan ge this line
  // Only change code above this line
  const arr = list;
  return arr;
  
}

const arr = removeFirstTwo(source);
console.log(arr);
console.log(source);

не работает мой код

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Please actually say more than “code doesn’t work “

Why did you add this change?

You need to read and obey these comments.

Но я не понимаю как изменить строку const arr = list;я думаю она уже изменена,по этому я и не понимаю вопроса,в задание сказано опустить две переменные,а тут целая головоломка не чего понять не возможно.

You should have never added this line. It is right below a comment saying you must not make changes.

I would reset the code and obey the comments.

I don’t understand the phrase “nothing to understand the whole puzzle”. There is an example of the exact syntax you need included in the instructions.

Я запутался в этом задание я его не понимаю,если надо вывести source а я указываю list,тогда как мне это связать?я не понимаю форму писания кода.

Did you reset the code?

The challenge is asking you to use “destructing syntax” to remove the first two items of list. You should only change one line of code.

да я сбросил код,и написал одну строчку кода но не чего не работает

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line
  const[a,b, ...arr] = list;
  const arr = list; // Change this line
  // Only change code above this line
  return arr;
}
const arr = removeFirstTwo(source);

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

This still should not be there.

Please read and obey the comments.

‘change this line’

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
  // Only change code below this line
  //...
  const[a,b, ...arr] = list; 
  //...
  // Change this line
  // Only change code above this line
  return arr;
}
const arr = removeFirstTwo(source);

так?

Please format your code.

You did not say enough for my translation tool to work.

You need a space after const

Код заработал,только я не понимаю как source относиться к list,если в блоке я не указывал source?