CSP U7L6 '21-'22 Activity Guide
CSP U7L6 '21-'22 Activity Guide
Directions: Go to Code Studio Unit 7 Lesson 6. Follow the instructions listed below at each
level.
Level 1
Run this program and read the code carefully. Try several different inputs.
● Describe what happens when the button is clicked:
Open the functions drawer and look at each of the StateLibrary functions. Mouseover them for
documentation.
● Make a prediction on how these functions work (code used in order to do what the
documentation says):
Click "Manage Libraries" in the gear menu, then hover over “State Library” and click "view
code".
● Read the code.
● How do the library functions work?
Level 1 Reflection
● What are the benefits of hiding all of the code for filtering the dataset in a library?
● What information does the user need to know in order to use the library functions?
Level 2
Run this program and read the code carefully. Try several different inputs.
Open the functions drawer and look at each of the StringsLibrary functions. Mouseover for the
documentation.
● How do these functions work?
Level 2 Reflection
● Why should we test the functions in the library?
● How can you make sure that the end users of your library have what they need in order
to use your functions?
Final Reflection
Up to this point, you have either created your own algorithms from scratch, or modified existing
ones (usually in Investigate Lessons). Now you have another tool to use combining existing
algorithms to make new algorithms. Today, this was accomplished with a library.
● What are the benefits of using existing algorithms instead of brand new algorithms?
Takeaways:
Highlight any takeaways below that you still have questions about or need help with. After
highlighting a takeaway that you still have questions about, go ahead and add your questions
next to or below the takeaway you need help with.
● Creating a library:
○ Build functions
○ Add documentation
○ Share as a Library
● Using a library:
○ Click "Manage Libraries"
○ Either choose a classmate's library, or paste in a library code
○ Call the functions by writing the library name, a dot, the name of the function, and
including any arguments for the parameters
● Testing a library:
○ Use console.log as the end user to test functions in a library
○ Check that the output is what you would expect
○ Read the library code if something does not work correctly, and contact the
library owner if something needs to be changed.