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

What is Framer? Join the Community
Return to index
Taylor Wright
Posted Jan 17 - Read on Facebook

In CoffeeScript, how can you swap two spans (slices) in an array.
In the following example I'd like to swap the A's with the B's
[0, 1, A1, A2, B1, B2, B3, 7, 8]
[0, 1, B1, B2, B3, A1, A2, 7, 8]


Jordan Robert Dobson

look at the lodash documentation... I bet something there would be helpful.

Taylor Wright

Neither of these really helped, I kept looking at the CoffeeScript docs to figure out how they handle slices and splices and came up with this:

Marc Krenn

Haven't implemented any error-catching (yet) but it seems work fine as long as the both ranges don't overlap.

Read the entire post on Facebook