Скажите, пожалуйста, что я делаю не такю Никак не могу пройти тестю Уже 3 дня мучаюсь

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

Your code so far

function nextInLine([arr, item]) {
  // Only change code below this line
 arr.push(item);
 return arr.shift();// Only change code above this line
}

// Setup
const testArr = [1, 2, 3, 4, 5];

// Display code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6));
console.log("After: " + JSON.stringify(testArr));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36

Challenge: Basic JavaScript - Stand in Line

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

Скажите, пожалуйста, что я делаю не такю Никак не могу пройти тест
Уже 3 дня мучаюсь.

Извините, я не говорю по-русски. Так что, если Google Translate ведет себя странно, извините. Можете ли вы сказать мне, что здесь происходит в параметрах вашей функции?

Sorry, i don’t speak Russian. So if google translate is being odd, sorry. Can you tell me what is going on here in your function parameters?

Hi, your explanation in russian is actually looks decent to me. I am a native russian speaker.

If it will be not clear enough for the topic creator, I can provide more explanations in russian.

1 Like

В нашем задание говорится: Добавьте число в конец массива.
Масcив у нас [arr, item]. К нему, при помощи функции push, добавляем в конец масcива число item.
arr.push(item);
Затем мы должны удалить первый элемент массива
Я при помощи .shift()функции, удалила первый элемент из массива arr
arr.shift();
и сразу же вернула, этой же функцией элемент, который был удален.
return arr.shift();

У меня нет проблем с тем, как вы настроили все остальное, все выглядит хорошо для меня. Но в тесте есть //комментарии, в которых вас просят ничего не менять за пределами комментариев, что вы и сделали. Вы добавили скобки () к параметрам и непреднамеренно выполнили присваивание деструктуризации. Если вы проверите консоль внизу, вы должны сказать, что arr.push не является функцией, потому что вы пытаетесь использовать ее для чего-то, что не является массивом. Если вы используете console.log() и arr, и item, вы увидите, что не получаете массив, вы получаете значения из массива (testArr), который передается функции nextInLine.

I don’t have a problem with how you set everything else up, that all looks good to me. But the test has //comments asking you not to change things outside the comments, which you did. You have added brackets () to the parameters, and unintentionally did a de structuring assignment. If you check the console at the bottom it should be saying arr.push is not a function, because you are trying to use it on something that is not an array. If you console.log() both arr and item you will see you not getting an array, you are getting values from the array (testArr) that is being passed to the nextInLine function.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.