0
votes

EDIT: Took out the unnecessary bit

Not sure why i can't call this method - I get an error

"textNodes[1].options.aaah" is not a function:

  

  const textNodes = [{
    id: 1,
    room_id: 1,
    text: '"ZZZZzzzzZZZZZZzzzzzzzzzzZZZZZZZZZZZZZ"',

    options: [{
      text: "Wake up",
      setfadeMode: {
        fade: 2
      },
      nextText: 2,
      ahhh() {
        console.log("ahhh");
      },
    }, ],
  }, ];

  textNodes[1].options.ahhh();
I made you a snippet. Please correct the missing part so it is a minimal reproducible examplemplungjan
"the index is tied to the ID" I don't think that is true.AlveMonke
What is textNodes here? And what argument would go as textNodeIndex? What are you trying to perform with the code? Why do you think the index is tied to the ID? Please clarify your question.AlveMonke
You want to invoke ahhh and not aaah?Oluwafemi Sule
your example is messed up in a few ways, but it looks like options contains an array, so something like textNodes[1].options[0].ahhh() would work. But really think about whether this is an appropriate data structure - if there really should be a full array of options then why call a method on just one of them?Robin Zigmond