Build a Smart Pantry Restocker - Build a Smart Pantry Restocker

Tell us what’s happening:

I don’t exactly understand what the groupByZone function is supposed to do, the wording of some problems in general is confusing and sometimes incomplete (no hate :slight_smile: ).Please advise on how to proceed

Your code so far

function parseShipment(arr) {
    let myArr = [];
    let ultArr = [];
    for (let ele of arr) {
        myArr.push(ele.split("|"))
    }
    for (let elem of myArr) {
        let newObj = {};
        newObj.sku = elem[0];
        newObj.name = elem[1];
        newObj.qty = Number(elem[2]);
        newObj.expires = elem[3];
        newObj.zone = elem[4];
        if (elem[4] === undefined) {newObj.zone = "general"}
        ultArr.push(newObj)
    }
    return ultArr
}

function planRestock(pantry, shipment) {
  let myArr = [];
  for (let i = 0; i < shipment.length; i++) {
    let myObj = {};
    myObj.type = "donate";
    for (let y = 0; y < pantry.length; y++) {
        if (shipment[i].sku === pantry[y].sku) {
            myObj.type = "restock"
        }
    }
    if (shipment[i].qty <= 0) {
        myObj.type = "discard"
    }
    myObj.item = shipment[i];  
    myArr.push(myObj)
  }
  return myArr
}

function groupByZone(actions) {

}

function clonePantry(pantry) {
  let newArr = structuredClone(pantry);
  return newArr
}

Your browser information:

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

Challenge Information:

Build a Smart Pantry Restocker - Build a Smart Pantry Restocker

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-smart-pantry-restocker/69a5f35669099ed52f8563b1.md at main · freeCodeCamp/freeCodeCamp · GitHub

Stuck at this and about to create post about it too
they only specify the test as “12. Your function groupByZone should return the actions grouped by the zone property of each object.”
and the user story is just
“3. You should implement a groupByZone(actions) function that groups the actions into storage zones based on each item’s zone property.”
OKAY but group it in WHAT? is it return an array of array of action objects that group by zone? or object that have zone name property which contain associate of action objects?

No hate. maybe I’m a dimwit that can’t stand againts the vagueness of programing so please enlight me too

I figured it out now

the function need to return object that have the zone name as property (like “general” or “fridge”) and in each property has value as an array of actions object (which you got from planRestock function)

I tried my best to follow your explanation, but I’m still not able to get my GroupByZone() function to pass the tests. Is there any way you could share an example of what a proper object of grouped actions looks like? It would be very much appreciated.

Welcome to the forum @solom.washing,

Take a look at the GitHub link included at the top of this topic. There you can find some good information about this challenge under the hints.

Hope that helps…