Solved but not sure when the array was generated

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


I solved this but expected to fail - I don’t understand when the array was created, i.e. I didn’t need to “return 'var arr = ” anywhere in the code block so I can’t see what generated the array in my correct solution.


  **Your code so far**

function mixedNumbers(arr) {
// Only change code below this line
arr.push(7, 'VIII',9)
// Only change code above this line
return arr;

console.log(mixedNumbers(['IV', 5, 'six']));
  **Your browser information:**

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

Challenge: Add Items to an Array with push() and unshift()

Link to the challenge:

The array was passed into the function as an argument. Your function shouldn’t overwrite arguments.

Here in the function call is where the array was defined.

Thanks Jeremy

As it’s in the console.log AFTER the code block I’m still confused.

Put another way, how is this different to when I’ve had to create an empty array at the start of a function?

Order has nothing to do with it. A function is not responsible for defining its arguments.

// This line has nothing to do with creating arguments
function someFunction(argument1, argument2) {

When the function is called

let result = someFunction(42, [1, 14, 'IV']);

this line basically says “do what someFunction says to do, and use argument1 = 42, argument2 = [1, 14, 'IV'].”

Gotcha, brilliant, thank you!

Sure thing. It can take a bit to get used to the difference between a function definition and a function call.

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