Directions: Go to Code Studio Unit 7 Lesson 6. Follow the instructions listed below at each level.  

Level 2

Run this program and read the code carefully. Try several different inputs..

The computer outputs the state chosen by the user along with 3 pictures and symbols of the state. When you don't input a state it says not found.

Open the functions drawer and look at each of the StateLibrary functions. Mouseover them for documentation.

Click "Manage Libraries" in the gear menu, then hover over “State Library” and click "view code".

The functions will output images of the skyline, seal, and flag of the specific state chosen by the user. For example StateLibrary.stateSkyline(stateName)

will output the state's skyline that the user inputs. If the state does not exist it will show the code.org logo.

Yes, our predictions were correct.

Level 2 Reflection

It makes the code easier to understand and less messy. It also makes the code shorter and more precise. It also makes it easier to share and copy.

The library name and functions inside and the parameters and return values


Level 3

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.

The first function returns the first letter of whatever word is imputed, the second function displays every part of the word except for the first letter of that word, the third function will add a vowel in this case “a” after the first letter of the word that has been imputed (returns true if vowel found, returns false if not), and the fourth function creates a list of new letters.

Test the functions:

Re-read the documentation for each library function.

Do This: Add a console.log() statement to the end of the program and call a function.

Do This: Hit run to see the output.

Do This: Now add console.log() statements to test the rest of the functions.

Do This: Try several different inputs.

Yes, it is what we expected.

Level 3 Reflection

So we can find out what the function does

Helps us to know how to use the app


Level 2 - Part 2

Navigate back to the States App

Do This: Add console.log statements for each of the functions and test them out.

The state abbreviation put the abbreviation and the other two put the link instead of the image.If the state doesnt exist or if a random word is imputed then it will output as “not found”  

Level 2 Reflection Part 2

They don't use global variables, take in parameters and have a return value, and add documentation.

Make sure you add comments and everything that was said above, if there is an issue let users know.


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.

If you use an existing algorithm your code will more than likely work and not have any errors. It will also save you time if you need something done quickly and if you don’t know how to code something it will save you from that too.

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.