Problem Set: User Input

This section contains a number of selected problems for the User Input section.

It is recommended that you review the problems, and complete a few before moving on to the next section.

Problem #1: Repeat After Me

You’re a pretty rad person. You want your computer to be rad too.

Create a program where the computer asks you what it should say, and then ||game:game.splash||es your response.

Problem #2: You Said This

You want to keep a log of things that you say.

Create a program where the computer asks you for input, and console.log what you say, but add the phrase “You said “ before what you actually said.

Problem #3: (Repeatedly) Repeat After Me

You often find yourself repeating the same thing over and over again.

Create a program where the computer asks you what it should say, but this time, make it so the program ||game:game.splash||s your response twice.

Problem #4: Animal Kingdom

You want your computer to learn about the animal kingdom. Create a program that allows you to “teach” your computer.

It should first ||game:ask|| for an animal name. After you respond, the computer should ||game:ask|| you what sound this animal makes (this prompt should include the name of the animal you first described). After you respond again, the program should repeat back to you “The animal goes sound“, with animal being your first response, and sound being your second response.

Problem #5: You Said, They Said

You and a friend want to keep a log of your conversation. Create a program that will do this for you.

The program should first ask for your name, followed by your friend’s name.

Then, it should ||game:ask|| first what you said, and then ask what your friend said. Finally, the computer should console.log a transcript of the conversation (for example, “James: What’s your favorite color?”, “Julia: My favorite color is green.”).

Challenge: record a longer portion of the conversation, by asking what each person said (and then logging that) multiple times.