Why there should be two variable in the parentese of functions?

  1. why there should be two variables in the parentese of functions?

  2. what are their roles?

example code below:

function nextInLine(arr, item) {
  // Only change code below this line
  return item;
  // Only change code above this line


// Setup
var 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));

Could you please provide more details about the challenge so that we can tell what are they.

yes, I don’t understand arr and item in the parentheses?

it is this challenge:


number 54

the arr is used for passing the Array and the other is used as an element to add to the array,


@coded-hola thank you

1 Like

Just for clarification here, A parameter is basically a variable that the function takes, so in the background, it creates a local variable for the function itself. It will use the value that was given to the function. For example:

function helloWorld(sentence1, sentence2) {
  return sentence1 + sentence2;

console.log(helloWorld("hello", "world")); //this will output helloworld.

You can name your parameter with any name, but always try to name it with something explanatory, that you can always understand what the parameter is holding, that’s why arr is holding an array. Learn more about parameters here:

1 Like

and where have you defined the variables hello and world?