<p>To add text items together in Javascript is super easy, you just use the <code>+</code> operator, which is 'overloaded' so that when the either term in an expression <code>x + y</code> is a string, the output is the first and second terms concatenated, as a string.</p>

<p>So you can just use <code>+ "%"</code> to add a "%" symbol to the end of a number. Works for any character, e.g. <code>123 + "-foo"</code> would result in <em>123-foo</em>.</p>

<p><strong>TL;DR:</strong></p>

<pre><code>effect("Slider Control")("Slider") + "%" 
</code></pre>

<p><strong>Note</strong> that the result of the slider will be a float (i.e. a number with lots of decimal places). That might not be what you're looking for. You can round it to an integer by using the <code>Math</code> functions, specifically <code>Math.round</code> (rounds to nearest integer) or <code>Math.floor</code> (always rounds down).</p>

<pre><code>Math.round(effect("Slider Control")("Slider")) + "%" 
</code></pre>

<p><strong>For extra credit</strong>: If you did want some decimal places, say 2 decimal places, then multiply the number by 100, round it and then divide by 100:</p>

<pre><code>Math.round(100 * effect("Slider Control")("Slider"))/100 + "%" 
</code></pre>

CC BY-SA 4.0
2019-01-04T08:50:17.537Z
It was easy! Thank you so much, your answer will be really helpful when playing with this kind of string.
Apeiron_Sound
CC BY-SA 4.0
2019-01-04T10:37:36.537Z
The Adobe docs for expressions are here: https://helpx.adobe.com/after-effects/using/expression-basics.html I'd also suggest having a look at some basic JavaScript tutorials such as the ones at https://www.w3schools.com/js/default.asp Although aimed at Web development a lot of it is applicable for expressions, including some JS features not documented in the Adobe docs.
stib
CC BY-SA 4.0
2019-01-04T04:39:00.827Z
2019-01-04T04:48:11.987Z
2019-01-04T04:48:11.987Z
stib
<p>I have a <em>text layer</em> (property: <em>Source Text</em>) connected to a <em>slider control</em>, in the way that the slider goes from <em>0</em> to <em>40</em> and the text layer simply follows the same amount. </p>

<p>Now, I want to have a fixed symbol which it will be "<em>%</em>" next to the number but of course with the current expression:</p>

<blockquote>
  <p>effect("Slider Control")("Slider")</p>
</blockquote>

<p>It is not possible to have a symbol since the expression tells the text layer to follow the value of the slider.</p>

<p>Must be super simple but I don't have the knowledge to fix the expression.</p>

<hr>

<p><strong>The final result would be the text layer going from 0% to 40%</strong> </p>

<p>Thanks in advance.</p>

<after-effects><after-effects-expressions>
Keep fixed symbol on a source text linked expression
Apeiron_Sound
# Keep fixed symbol on a source text linked expression

(Asked by: username_0 on 2018-11-14)

I have a *text layer* (property: *Source Text*) connected to a *slider control*, in the way that the slider goes from *0* to *40* and the text layer simply follows the same amount.

Now, I want to have a fixed symbol which it will be "*%*" next to the number but of course with the current expression:

> effect("Slider Control")("Slider")

It is not possible to have a symbol since the expression tells the text layer to follow the value of the slider.

Must be super simple but I don't have the knowledge to fix the expression.

---

**The final result would be the text layer going from 0% to 40%**

Thanks in advance.

**Tags:** after-effects, after-effects-expressions


---

## 1 answers

### Answer by username_1 on 2019-01-04. Score: 1 | Accepted answer

To add text items together in Javascript is super easy, you just use the + operator, which is 'overloaded' so that when the either term in an expression x + y is a string, the output is the first and second terms concatenated, as a string.
So you can just use + "%" to add a "%" symbol to the end of a number. Works for any character, e.g. 123 + "-foo" would result in 123-foo.
TL;DR:
effect("Slider Control")("Slider") + "%" 

Note that the result of the slider will be a float (i.e. a number with lots of decimal places). That might not be what you're looking for. You can round it to an integer by using the Math functions, specifically Math.round (rounds to nearest integer) or Math.floor (always rounds down).
Math.round(effect("Slider Control")("Slider")) + "%" 

For extra credit: If you did want some decimal places, say 2 decimal places, then multiply the number by 100, round it and then divide by 100:
Math.round(100 * effect("Slider Control")("Slider"))/100 + "%"

> **Comments:**
> **username_0**: It was easy! Thank you so much, your answer will be really helpful when playing with this kind of string.  
> **username_1**: The Adobe docs for expressions are here: https://helpx.adobe.com/after-effects/using/expression-basics.html I'd also suggest having a look at some basic JavaScript tutorials such as the ones at https://www.w3schools.com/js/default.asp Although aimed at Web development a lot of it is applicable for expressions, including some JS features not documented in the Adobe docs.  

---

