From 2934af883585562512dd98a781a0cfb6adfc25e3 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Sat, 24 Dec 2022 07:58:07 +0100 Subject: [PATCH] :pencil: Explain how code works in Set variable block --- .../docs/editor/blocks/logic/set-variable.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/apps/docs/docs/editor/blocks/logic/set-variable.md b/apps/docs/docs/editor/blocks/logic/set-variable.md index 40e52516e..57f3b31f0 100644 --- a/apps/docs/docs/editor/blocks/logic/set-variable.md +++ b/apps/docs/docs/editor/blocks/logic/set-variable.md @@ -38,6 +38,27 @@ Compute a percentage: {{Score}} * 100 / {{Max Score}} ``` +## Code + +The code value should be written Javascript. It will read the returned value of the code and set it to your variable. + +```js +const name = 'John' + 'Smith' +return name +``` + +If you don't provide the `return` keyword then it will be automatically prepended to the beginning of your code. + +```js +'John' + 'Smith' +``` + +is the same as + +```js +return 'John' + 'Smith' +``` + ## Current Date You can create a `Submitted at` (or any other name) variable using this code: