3. Edit the Conditional Statement

Playback Speed:

In the previous video, you typed words into the talkbot to figure out how it works.

In this video, you’ll make changes to the code so your talkbot responds to different prompts.

Then, you’ll add more prompts to tell your knock-knock joke.

Return to the script editor to change the strings in the code.

In this case, the strings are the words “hi” and “hello world.”

Since you’re creating a talkbot that tells jokes, change the word “hi” to “joke.”

Don’t delete the single quotation marks – that’s how the computer knows you’ve written a String.

Then, change the words “hello world” to “knock knock.”

Now when you ask the talkbot to tell you a joke, it will respond by saying “knock knock.”

To try it out, save your project.

Then, return to the tab in your browser with your talkbot, and reload the page.

Type any phrase with the word “joke” in it.

The talkbot should have responded with “knock knock.”

If your talkbot doesn’t work, you may have made a mistake in your code.

That’s okay.

It’s an important part of the coding process.

Look carefully at your code again and make sure it matches what you see on screen exactly.

If you can’t figure out what’s wrong, ask for help.

Just like in most professions, software engineers work together, build on one another's work, and make lots of mistakes as they learn.

Errors stop your code from working.

To remind yourself about what this conditional statement does, add a comment.

It doesn’t do anything; it just acts as a reminder or note.

Software engineers often collaborate, or work together on code.

Comments help you and whoever works on the code after you better understand each section.

Comments begin with two slashes and are one line long.

There are already some comments in this code.

Above your conditional statement, press Enter or Return to move it.

Then, type two slashes and a space to start your comment.

Type a sentence to remind you about what this conditional statement does.

Save your code again...

and reload the web app.

Then test your talkbot again.


  1. Edit your code by changing “hi” to “joke” and “hello world” to “knock knock.”
  2. Test it again by saving your code and reloading the talkbot.
  3. Debug.
  4. Add a comment to describe the conditional statement.
  5. Save, test, and debug your code.