I have a list of clothing items and a variable [gender] that contains value for example “♂️” male. Some items on the list of clothing also contain emojis ♀️ or ♂️ in them, something like “Batman suit♂️”. I’m trying to exclude all items with ♀️ if “gender==♂️” and vice versa. I’ve tried to use clothingTop.selectAll.filter(newlist =>newlist.tags.includes([gender])), ald also match(/♀️/i), I’m not sure how to proceed.

  • Koto@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 month ago

    How do I work with $output now in the list section to call an individual item from the list? I used to do it like this [clothingList[clothingGroup][clothingTop].joinItems(", ")] where clothingGroup is the html optgroup and clothingTop is the name of the item(‘this.value’). ${clothingTop[clothingGroup][clothingTop]} or clothingList[clothingGroup][clothingTop] returns undefined. Sorry for the noob question, as you can tell I’m new at this :-)

    • VioneT@lemmy.worldM
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 month ago

      I forgot to enclose the value=${this[a]} with quotations, so that is one problem. You can remove the value of the option if you are using the value to access back the list like so:

      $output = [this.selectAll.map(a => a.getName).filter(a => gender.includes('♀️') ? !a.includes('♂️') : !a.includes('♀️')).map(a => `<option>${a}</option>`).join('')]
      

      So that clothingTop will return the list name e.g. Dress♀️, then using it with [clothingList[clothingGroup][clothingTop]] should return the item below it i.e. evening dress with deep neckline.

      Setting the value to this[a] would have the value of the option set directly to evening dress with deep neckline and not Dress♀️ so [clothingList[clothingGroup][clothingTop]] would not work, but you can access the value directly with clothingTop.

      • Koto@lemmy.worldOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 month ago

        Yeah that works, much appreciated! I noticed that the value was different from the name, it was lowerCase and no emoji that’s why I couldn’t call it.