Problems in Stand in Line

Tell us what’s happening:
Dear All,
Good afternoons,

I would like ask you in which cases can we use the vertical bars, or specifically why we used it in this challenge? i saw some solutions posted in the forum that´s why i used it but sadly i don´t understand what ´s the reason of its usage. I send you all a picture of my code and i thank you in advance any orientation provided.
Have you all a wonderful day,
Kind regards,
Ivonne

Your code so far


function nextInLine(arr, item) {
  // Your code here
  testArr.push(item);
  testArr.shift(arr[0]);
  return arr[0] || 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, 1)); // Modify this line to test
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/76.0.3809.132 Safari/537.36.

Link to the challenge:

Ivonne,

they are shorthand and are very useful when you want to get the value that is casted to true (and when you are sure that one of the values will be casted to true so it will be returned in this case)

Dear @flyingeagle,
I thank you so much and appreciate your fast explanation and help :slightly_smiling_face:
since i am new in Js , all information provided is very well received.
Have a beautiful day,
Kind regards,
Ivonne

Just because someone used this syntax in their solution doesn’t mean that you have to. You can solve this challenge using the information that you already know.

Dear @ArielLeslie,
Good afternoons,
I appreciate your kind reply, being honest with you it was hard to arrive to a solution,
and i understood the use of .shift() and .push() but when i arrived to the part of the return
it was not so easy to understand, that´s why i read some posts and i found || vertical bars.
Anyway i truly thank you and appreciate your advises,
Kind regards,
Ivonne