Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:33
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:11
    thecodingaviator labeled #31179
  • Apr 01 18:09
    thecodingaviator commented #31179
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:09
    thecodingaviator labeled #31182
  • Apr 01 18:07
    thecodingaviator commented #31182
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator labeled #31190
  • Apr 01 18:07
    thecodingaviator commented #31190
  • Apr 01 18:05
    thecodingaviator commented #31157
  • Apr 01 18:04

    thecodingaviator on master

    remove A (#31157) (compare)

  • Apr 01 18:04
    thecodingaviator closed #31157
  • Apr 01 18:04
    thecodingaviator closed #33788
  • Apr 01 18:04
    thecodingaviator commented #33788
  • Apr 01 18:02
    thecodingaviator closed #31059
  • Apr 01 18:02
    thecodingaviator commented #31059
Arnaud Casamé
@arnaudcasame
@Krystinet first push the item, and then shift the array into item
Joseph
@revisualize
But, you know.. meh.
KT
@Krystinet
Do I have to set arr and item to something?
Arnaud Casamé
@arnaudcasame
@Krystinet
Joseph
@revisualize
@Krystinet No.
@Krystinet They are parameters.
You know.. That big block of text that I just posted. With images ans stuff.
Arnaud Casamé
@arnaudcasame
@revisualize loll
KT
@Krystinet
sorry guys, im really being dense on this one

function nextInLine(arr, item) {
// Your code here
arr.push();
item.shift();
return item; // 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));

Joseph
@revisualize
@Krystinet item isn't an array.
MoNag1
@MoNag1
@Krystinet you should shift arr and not item
Joseph
@revisualize
@Krystinet function nextInLine which has two parameters an array (arr) and a number (item).
MoNag1
@MoNag1
@Krystinet also, you will need a place to store the new array after the first item has been removed
Arnaud Casamé
@arnaudcasame
@Krystinet
item = arr.shift()
KT
@Krystinet

function nextInLine(arr, item) {
// Your code here
arr.shift();
arr.push();
return item; // 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));

Joseph
@revisualize
@Krystinet Why did you change the order?
KT
@Krystinet
Ahhh
I DONT KNOW
jrr5230
@jrr5230
@Krystinet I think you should take the time to understand the whole block of info that @revisualize posted :)
Joseph
@revisualize
@Krystinet :point_up: November 22, 2016 7:26 PM
Arnaud Casamé
@arnaudcasame
@Krystinet
KT
@Krystinet

function nextInLine(arr, item) {
// Your code here
item = arr.push();
item = arr.shift();
return item; // 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));

Joseph
@revisualize
@Krystinet Why are you overwriting item?
Arnaud Casamé
@arnaudcasame
@Krystinet

function nextInLine(arr, item) {
  // Your code here

 arr.push();
item = arr.shift();
  return item;  // 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));
Joseph
@revisualize
item is the number that you need to be adding to the end of the array?
@djcase001 Also wrong.
Arnaud Casamé
@arnaudcasame
@revisualize that's how i solved it
Joseph
@revisualize
With this lesson there is Zero need to overwrite item.
@djcase001 Then you never added item to the end of the array.
Arnaud Casamé
@arnaudcasame
@revisualize You're maybe the one who's wrong there
Joseph
@revisualize
Maybe I am.
jrr5230
@jrr5230
I did it completely different @djcase001
like @revisualize no need to overwrite
KT
@Krystinet

function nextInLine(arr, item) {
// Your code here
arr.push();
arr.shift();
return item; // 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));

now back to this, since item does not get over written?
Joseph
@revisualize
@djcase001 Could you critique my code and tell me if I'm wrong?
function nextInLine(arr, item) {
  arr.push(item);
  return arr.shift();
}
I am pushing item to the end of the array ... because that is what push does.
I am removing the first element from the array because that is what shift does.
jrr5230
@jrr5230
@Krystinet you have to push in an item into the array
Joseph
@revisualize
But, shift also returns the element that was removed.
So... It satisfies the requirements.
@djcase001 Please let me know where my code is wrong. I'd love to hear it.
...
Look, I'm not trying to sit here and be an ass.
There is a reason that this lesson has
// Change this line
jrr5230
@jrr5230
looks right to me +1:
Joseph
@revisualize
You need to change that line.
I played the game Clue once or twice and I got Clue.

The push() method adds one or more elements to the end of an array and returns the new length of the array.

The shift() method removes the first element from an array and returns that element.