# Customized repetitions

When you apply a _Repeat_ modifier to a shape, it makes copies of the original shape. The number of copies is controlled by the `repetitions` parameter. Since modifiers are live, changes you make to the original shape are propagated to all of the copies.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/178d04df608b638a27b5f8f4c19f8fdd0d10484e8aa4697adf6c0336ca3412d9.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

But what if you want to make each copy different? We can do this using Cuttle’s _Customized Repetitions._

## **The “rep” Variable**

When “Customize Each Repetition” is checked, any shape or modifier that comes before the repeat modifier will have access to a variable called `rep`. This variable holds the index of repetition, and can be used to differentiate the copies.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/7d8871acbfec158cd08fa5f1a7ad80601ca38caa7684838763f20a7eaba4c60f.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

Let’s try using the `rep` variable in the Star shape’s `points` expression.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/420589ab57aa7dd182aa4eb89439f5c8d62395bd8b0bc3c4131acdc1c4770f1d.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

Now each star has a different number of points!

**Note: The inspector always shows expression results from the first repetition, where** `**rep === 0**`**.**

## **Example: Linear Scale**

We can also use `rep` to customize Transforms. Here we apply a Linear Repeat to a Rectangle and use its `rep` variable to scale uniformly along the Y axis.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/aed122400df65747616bcd3a596212d0093a765654da52e23a357ff6bc0a2c8f.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

## **Example: Clock**

Let’s use a Rotational Repeat to make a 12-hour clock.

First, drag out a Text component and add a Rotational Repeat modifier and set `repetitions` to 12 (the total number of hours).

## **Renaming “rep”**

Like component and project parameters, the `rep` variable can be renamed. Double-click the `rep` variable and rename it `hour`.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/d8f95cd415f0de5052319068812f611e9cbc29f1a02e8bc607dcc7ffef7791ef.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

## **Setting the text Expression**

We can then click “⋯ → Edit Expression” next to the “text” parameter. In the expression, enter the name of our rep variable `hour`.

You’ll notice that the number on top reads “0” when it should be “12”. We can use JavaScript’s [ternary operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator) to add a special case for this.

Write `hour === 0 ? 12 : hour` into the text expression. This means “If hour is 0, return 12, otherwise return hour”.

![](https://cuttle-content.imgix.net/learn/customized-repetitions/d54ba78df493d84b668ca4d058227e8b7332f90d5c28722341dc6fd253e89ea9.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)

Alternatively, this can be written more verbosely as a multi-line expression:

if (hour === 0) return 12; return hour;

## **More Examples**

Check out the [Customized Repeat Examples](https://cuttle.xyz/@notlion/Customized-Repeat-Examples-ZL6lpqqaXYpv) project for more ideas!

![](https://cuttle-content.imgix.net/learn/customized-repetitions/65019b05d5546c8fff35738e7741ceb1e5beb8443513bce0e5e8378252ba1cd0.png?auto=compress,format&q=60&fit=max&w=720&h=720&dpr=2)