i’m trying to make a function that creates a multi-level list. i’ve got function code that makes a single-level list, and that works fine, but my attempted extrapolation of that code to make a two-level list isn’t working. could anyone tell me what i’ve done wrong and how to fix it?
thank you in advance! <3

  • VioneT@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    Linking the generator would be helpful to also see your previous attempts. Also, i’m not sure if I understand but, you want a prA variable that holds the values from the input? You can do that without having it inside the function like so:

    prA
      sub = ''
      obj = ''
      det = ''
      pos = ''
      ref = ''
    

    Also, you can directly have the variables on the function like so, without needing to create a list inside of it:

    makePronounList() =>
      let sub = []
      let obj = []
      let det = []
      let pos = []
      let ref = []
      ...
    

    If you want to create a new ‘list’ from the user’s input, see this user input example.

    • starrymoonbow@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      10 months ago

      here’s the link to my generator: https://perchance.org/dcpau0freu#edit.
      i’m trying to make a list called prA (meaning pronoun A) that holds several single-item lists (sub/obj/det/pos/ref) that each contain a value from each input. (i need them to be in the list prA because i want to make five more separate pronoun lists like it, one for each Person.) this much of the code is working fine.
      my issue is that i would like the values to receive the highlight color to match the color that “Person A” is highlighted in. in my current code, it seems to be ignoring the function that should be applying the highlight color. i’m very inexperienced with HTML and javascript, so i’m not sure how to edit the function to make it work.

      • VioneT@lemmy.worldM
        link
        fedilink
        English
        arrow-up
        2
        ·
        10 months ago

        See this modification of your generator

        On that generator, I essentially hard coded all of the items that you dynamically need to create. It is much easier to use since you can change those values with inputs easily instead of pushing stuff into an array which might throw errors.

        • starrymoonbow@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          10 months ago

          oh that’s interesting! it works nicely i think, but there’s just one problem. i’d like for the highlight to apply automatically to the names and pronouns, even when edited by user inputs, which is why i was going through a function that applied the formatting to the names, and attempted to do the same with the pronouns. if that isn’t possible, i understand, it would just make editing more convenient for me. thank you for helping me this far! :0