Skip to Content
0
May 29, 2021 at 04:46 PM

Looping through an Array

504 Views

Hello, once again i need help with scripting in CAI...

i have an array of objects (a list of values, organized by categories)

facts = [
{ cat:0, id:0, value:"blabla", seen:0}
, {cat:0, id:1, value:"xyz", seen:0}
, {cat:0, id:2, value:"this and that", seen:0}
, {cat:1, id:0, value:"whatever", seen:0}
, ... ]

i also have a counter that specifies which item in this array i'm currently at (=which one is supposed to be used/checked next) and a variable that defines what the current category of interest is

facts_counter = 0

facts_cat = 1

two questions:

A. how do i loop through the facts-array, starting at the item defined by facts_counter, to show the value of the next object that matches the current category defined in facts_cat?

B. and how do i set the value of "seen" to 1, for this specific item just found?

all hints&help highly appreciated!

thx+best regards

matthias