Im not really a programmer so please excuse the slightly crude description. This is an expression for a textlayer in Adobe After Effects (which uses Javascript)
I currently use this expression to generate an array of values (which is later used as customizable labels for the axes of a graph)
x = 0 //starting point (the first number in the list)
y= 20 //increments (the size of the steps)
z= 5 //the number of steps
Array.from(new Array(z)).map((_, i) => i * y + x + "km").join("n")
which outputs
0km
20km
40km
60km
80km
Then I thought it would also be good to have miles in there so I changed the code to this
Array.from(new Array(z)).map((_, i) => i * y + x + "km " + (i * y + x) * 0.6 +"mi").join("n")
I suppose its not beautiful but it does the job …
0km 0mi
20km 12mi
40km 24mi
60km 36mi
80km 48mi
I then tried to add a customizable fontsize. Thats how I did it.
text.sourceText.style.setText
(
Array.from(new Array(z)).map((_, i) => i * y + x + "km " + (i * y + x) * 0.6 +"mi").join("n")
)
.setFontSize(20)
This worked, but really I only want a different font size for the miles value and this is where I ran into trouble. I tried
Array.from(new Array(z)).map((_, i) => i * y + x + "km " + text.sourceText.style.setText((i * y + x) * 0.6 +"mi").setFontSize(10)).join("n")
but this somehow only outputs
0km [object Object]
20km [object Object]
40km [object Object]
60km [object Object]
80km [object Object]
any ideas? Thanks in advance