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

What is Framer? Join the Community
Return to index
Marc Krenn
Posted Oct 21 - Read on Facebook

What's the best practice for accessing elements within a two-dimensional arrays?

Here's an example (http://share.framerjs.com/pz53e6ly67tf/) in which the clicked layer gets switched with a random layer from a pseudo-2D array.

It works fine using this pretty simple, yet inelegant method of (simply put) multiplying and adding rows to columns, but there must be a better way to do this in coffeescript ... I suspect by using .map!? Can anyone give me a hint how this example would work with .map (especially the part where a random layer is picked from the array).

Thanks!

2 Comments

Koen Bok

Looking through the code, this looks pretty much like how I would do it. I think it looks pretty clean.

Koen Bok

Is there anything specific that bothers you about the code? Maybe I'm overlooking something.

Read the entire post on Facebook