This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Michael Bing
Posted May 08 - Read on Facebook

How can i loop though an array, and create another array?. I have this code, but it does not wanna work.

layerPos = []

Kristofer Samuelsson [6:04 PM]
layerPos[key.name] = [key.x, key.y]

But i all get is an array of empty arrays.

Cheers

2 Comments

Balraj Chana

You can insert new elements into an array using .push.

layerPos = []

for i in [0..3]
layer = new Layer({
name: "layer #{i}"
x: i * 200
})
layerPos.push layer.name, layer.x, layer.y

print layerPos

Michael Bing

No worries, got it to work :)

Read the entire post on Facebook