Build a Lunch Picker Program - Build a Lunch Picker Program

Tell us what’s happening:

hi am failing tests 24, 25, and 29, 30 the more i try to solve it the more confused i am getting, any pointer greatly appreciated

Your code so far

let lunches = [];

function addLunchToEnd(lunches, str) {
  lunches.push(str);
  console.log(`${str} added to the end of the lunch menu.`);
  return lunches;
}

function addLunchToStart(lunches, str2) {
  lunches.unshift(str2);
  console.log(`${str2} added to the start of the lunch menu.`);
  return lunches;
}

function removeLastLunch(lunches) {
  if (lunches.length !== 0) {
    let removed = lunches.pop();
    console.log(`${removed} removed from the end of the lunch menu.`);
  } else {
    console.log("No lunches to remove.");
  }
  return lunches;
}

function removeFirstLunch(lunches) {
  if (lunches.length !== 0) {
    let removed = lunches.shift();
    console.log(`${removed} removed from the start of the lunch menu.`);
  } else {
    console.log(`No lunches to remove.`);
  }
  return lunches;
}

function getRandomLunch(lunches) {
  if (lunches.length == 0) {
  console.log(`No lunches available.`);
} else if (lunches != 0) {
  let random = lunches[math.floor(math.random() * (lunches.length))];
  console.log("Randomly selected lunch: ${random(random)}");
}
}
function showLunchMenu(lunches) {
  if (lunches.length != 0) {
    console.log("Menu items: ${lunches}");
  } else if (lunches == 0) {
    console.log(`The menu is empty.`);
  }
  }

Your browser information:

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

Challenge Information:

Build a Lunch Picker Program - Build a Lunch Picker Program

Focus on one test at a time.

How did you investigate Test 24?

Do you have any questions?

so far i have been checking other peoples solutions on the forum and trying various things from there and refering back to the course notes

???

???

For Test 24:

  1. Are there any errors or messages in the console?
  2. What is the requirement of the failing test?
  3. Check the related User Story and ensure it’s followed precisely.
  4. What line of code implements this?
  5. What is the result of the code and does it match the requirement? (Write the value of a variable to the console at that point in the code if needed.)

If this does not help you solve the problem, please reply with answers to these questions.

thanks for trying to help this is just confuseing me so have deleted the code and will try again when i have done more reasearch

Ok.

Try to be systematic. Break things down and focus/test small pieces of your program independently.

Implement each User Story carefully, make sure you understand what it’s asking.

Try to pay more attention to the User Stories than the tests at first.

instead of deleting everything, call the function and test what it does

can you think of one function call you could use to test the function? what should it output?