Moving for loops in robtext to Array.forEach