logo

Using functions in PXT

QUESTION

How do I use functions in PXT?

How do I reuse code in PXT

ANSWER

1. make a little blocks program that beats a heart…

2. go into java script view to view ‘under the covers’ (press the JAVASCRIPT button at the top of the editor)

3. move the beating code into a beat() function with a bit of cut and paste and typing

4. go back to blocks view and see what it has done (press the BLOCKS button at the top of the editor)

5. use the beat() function (copy and paste) multiple times to create a bigger program, showing how a function allows reuse

ORIGINAL SOURCE

https://github.com/Microsoft/pxt/issues/325#issuecomment-299552975

0 found this helpful
All for Joomla All for Webmasters