Why can I not refactor this simple example into functions?

Hello all,

What is the difference between

and this where I simply move the same code into functions.

As you can see in the second example the animation is not triggered by the button.

Its not necessary in this simple example but I find it useful in larger project to organise the code is there some guidance on this topics somewhere else too?

Hey there, it looks like the missing step was just to return the animation from the addAnimation function and assign it to your rotate variable. :slight_smile:

Edit: ooh and just noticed and removed the extra rotation param from addAnimation too.

2 Likes

Thanks!

2 Likes