![]() hex file by clicking on the big download button on the bottom left of the JavaScript Blocks Editor. ![]() Testing the code on the board To test the code, simply download the. Finally, when using a function inside the placeholder, the returning value of that function was also replaced in the string. ![]() At the time of writing, I hadn’t yet figured out why the simulation engine is placing it in a different position from the others, but it seems like the simulation environment has changed a bit since the last tutorials. Please not that this string is localized in a different place of the simulation window, at the top. When we used the sum of two values in our placeholder, the result of the operation was replaced in the string. Note that the ribbon with the 2 value simply indicates that the same string was printed twice. On the opposite, when we used single and double quotes for the same string with the placeholder, there was no replacement. Then, in the second string, the placeholder was substituted with the value of the variable, which contained the string “World”. The first string remains unchanged since we did not use any placeholder. Note that the results are coherent with what we have stated in the previous sections. You can check below at figure 1 the expected result. Simulating the code As usual, you can simply test the code on the simulation environment of the JavaScript Blocks Editor. In JavaScript, which we will be using to program our micro:bit board, we perform string interpolation by enclosing our string in grave accents (“) and using $`) In short, string interpolation corresponds to evaluating a string that may contain some placeholders, in which the result corresponds to replacing the placeholders with their values. Introduction The objective of this post is to explain how to use string interpolation on the micro:bit board, using the JavaScript Blocks Editor. The objective of this microbit tutorial is to explain how to use string interpolation on the micro:bit board, using the JavaScript Blocks Editor.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |