Can't get my function to work in the playground

Apologies in advance if this is in the wrong category.

I can’t get functions to work in the playground area.
It doesn’t seem to accept a variable defined with () => {} as a function.
I can’t tell if I just don’t understand how it works or if it’s broken.

I don’t understand the syntax I’m supposed to use. Please help

1 Like

You’re right – that is a problem! To run your function, you need to use a function call which is the name of your function with parentheses after it, like this: myFunction() But the playground isn’t creating that button, it only creates the identifier for your function, myFunction, without the parentheses.

I’ve made a report of this issue, and hopefully we can fix it soon!



Thanks for responding.
I’m glad I could help :grin:

Again — thanks for flagging this issue!

In the meantime, if you’d like to test your own functions we have created another playground using the platform You can edit the javascript in the bottom left box to create your own function.


I created an animation in playground but can’t get it to work with lever.on(‘click’, fillTub).
Where fillTub is a function call. The only svg available is fillTub( ) but not the teal colored variable fillTub like other example code walkthroughs. It activated the function without tap on lever. Also wrote another function to just change color and it ran after loaded without the on-click event. Why can’t I insert the correct function call in the on-click event?

1 Like

I’m having a similar issue.

I was able to work around it by creating a variable at the beginning of the code, using that variable in the call, and then deleting that variable at the beginning. This only worked once, though. I tried it again with a second variable within my code, and it’s giving me a variable not defined error.