I cannot understand how did they store the Array and the number in Arr and item ??
I cannot see the code used to store these value :?
I cannot understand how did they store the Array and the number in Arr and item ??
I cannot see the code used to store these value :?
what’s the code you are talking about?
is it a solution found in the guide? one found in the forum? we need a link to it or you posting the code here
Assuming you’re talking about the “Stand in Line” challenge found here:
They are passing the [arr]
and item
on this line:
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test <-----------------
console.log("After: " + JSON.stringify(testArr));
-J
here is the link
HI JesseHope
Yes, that is the one I mean
However, I can see that one the bottom line there is console.log(nextInLine(testArr, 6));
but when I cancelled that or amended the code did not change
I cannot understand how that line is linked to the function and the place holder Arr
Can you post your code here please?
-J
this is only one function call, the one you should use to figure out if it works, each test uses its own function call to test your code, and will work even without the function call in the editor
function nextInLine(arr, item) {
// Your code here
arr.push(item);
var remove = arr.shift();
return remove; // Change this line
}
// Test Setup
var testArr = [1,2,3,4,5];
// Display Code
console.log("Before: " + JSON.stringify(testArr));
console.log(nextInLine(testArr, 6)); // Modify this line to test
console.log("After: " + JSON.stringify(testArr));
ok but let’s suppose I want to assign to Arr another name for the Arr instead to “testArr”…which part of the code should I change??
do you want to use a different array to call the function?
then you need to change the function call (example: nextInLine([9, 12, 13, 4], 9)
)
do you want to change the name of the array in the Test Setup section? Then you need to change the array declaration (var testArr = [1, 2, 3, 4, 5]
) and where it is used, in this case the function call
do you want to change how the array is referenced inside the function? then you need to change the function parameters:
function nextInLine(arr, item) { // those inside the parenthesis are the function parameters, they can have any name
// ...
}