79470229

Date: 2025-02-26 15:21:12
Score: 0.5
Natty:
Report link

I was able to get my page to work by type checking my items array.

export function getCollection(name) {
    let collection;
    if(name === "all"){
        collection = getAllProducts();
    } else {
        collection = collections[name];
    }
    const type = typeof collection.items[0];
    if (type === "string") {
        const items = collection.items;
        const map = items.map((x) => getImage(x));
        collection.items = map;
    }
    return collection;

The page works but I'm still baffled by this.
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Christopher Cardea