HISE Logo Forum
    • Categories
    • Register
    • Login

    Learning Objects || One last thing!

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 18 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ChazroxC
      Chazrox
      last edited by Chazrox

      See Prints:
      Screenshot 2025-07-12 at 9.51.59 PM.png

      Im able to print out everything I need....except for getting a loop to push values into an array then print out each item in the array.

      Im trying to loop over the animals.exoticObject array inside of an object to get all of its values.

      anybody got any pointers? What am I missing?

      Script:

      const animals = {};
      const newObjects = [];
      //-------------------------------
      
      const dogs = ["dog", "cat", "fish"];
      const cats = ["tigger", "felix", "sam"];
      const exotic = {"elephant" : "africa", "tiger":"asia", "panda":"china"};
      //-------------------------------
      
      animals.dogsObject = dogs;
      animals.catsObject = cats;
      animals.exoticObject = exotic;
      //-------------------------------
      
      for (k in animals.exoticObject)
      {
      	Console.print(k);
      	
      }
      //-------------------------------
      
      for (i = 0; i < animals.exoticObject.length; i++)
      {
      	newObjects.push(animals.exoticObject[i]);
      	
      }
      
      // Single Items
      Console.print(animals.exoticObject["elephant"]);	
      Console.print(animals.exoticObject.elephant);
      Console.print(animals.exoticObject.tiger);
      
      // Objects & Arrays
      Console.print(trace(newObjects));
      Console.print(newObjects);
      
      

      @d-healey

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @Chazrox
        last edited by Lindon

        @Chazrox said in Learning Objects || One last thing!:

        for (i = 0; i < animals.exoticObject.length; i++)
        {
        newObjects.push(animals.exoticObject[i]);

        }

        isnt it simply this?

        for (i = 0; i < animals.exoticObject.length; i++)
        {
        	newObjects.push(animals.exoticObject[i]);
        	Console.print("Item:" + animals.exoticObject[i]);
        }
        

        HISE Development for hire.
        www.channelrobot.com

        1 Reply Last reply Reply Quote 0
        • First post
          Last post

        20

        Online

        1.8k

        Users

        12.1k

        Topics

        105.4k

        Posts