Extra spaces are trimmed when printing to the console in Arcade, so you don’t have to worry about the extra spacing that comes at the end from printArray.
Problem Set: String Array Manipulation
This section contains a number of selected problems for the String Array Manipulation section.
It is recommended that you review the problems, and complete a few before moving on to the next section.
Problem #1: A Bit Pushy
Push and pop can be used to modify arrays, so that they store the values you want.
In the snippet below, printArray is used to print out each value in an array. Run the code, and notice the format of the output to the console.
Use push and pop to modify input, so that the call to printArray will output the following:
I like to program in MakeCode Arcade
Problem #2: While You Don’t Say That
You have somehow grown a distaste for the word “that”.
Write a small game that will continue to ask the user for a string until the user has inputted the word “that”. When that happens, splash “I don’t like that!” and end the game.
Problem #3: Pretty Printing
Fill in printArray below as described in the function comment. Make sure that the output for the three tests match the expected output listed in the comment on each line.
Problem #4: Chatty Bot
Create a simple “Chatbot”, that will ask the player for a string with the prompt being a random string from an Array you make. Be sure to fill up the Array with a number of prompts, to make the bot interesting!
During the conversation, maintain a “log” in the console, and identify whether the bot or user entered that. For example, this might look like the following transcript:
bot: what is your favorite color?
user: red
bot: how are you?
user: good
bot: what is your favorite color?