Close
Close full mode
logoMakeCode AP CSP

Arrays of Strings

String Arrays

Tasks A

Go to Activity: Arrays of Strings. Complete the following tasks with the sample code in Example #1.

Task 1a

  1. Use a for index loop to reduce the redundancy in princessMonologue, without changing the behavior of the code.
  2. Add (at least) three more strings to the text list array, describing what she had for lunch.
  3. Use length of array so that it will loop through the entire array no matter the size.

Shared project link:

Task 1a Challenge

After the princess has given her speech, make her say it again backwards.

Shared project link:

Task 1b

  1. Replace the for index from 0 to loop with a for element loop.
  2. Replace text list get value at index with the value parameter of the for element loop.
  3. Make the princess introduce herself and let us know what she had for lunch.

Shared project link:

Princess Dialog Mod

  1. MakeCode.com Princess Dialog 2 Game
  2. Mod this game to add an Enemy Sprite.
  3. Create a second Text Array that includes words the Enemy will say.
  4. When the Princess overlaps with the Enemy, have the Enemy randomly say one of the words from the Array.

Shared project link:

Tasks B

Extension activities - if you complete your activities early, here are some optional challenges.

Challenge 1

  1. Create a list of 10 names of friends.
  2. Create a function that searches the list for a specific name, returning the name if found, and a message of "name not found" if the name is not found.

Challenge 2

  1. Use your list of 10 names.
  2. Create a program that randomly selects the name "out of a hat".
πŸ“˜ Unit 5 - AAP Part 2 β€” Previous
String Arrays
Next β€” πŸ“˜ Unit 5 - AAP Part 2
Student Tasks/Solutions