Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 7 of 10

A request worth keeping

Show on a big screen

8 min

Text size

Save a good request with blanks in it. Fill the blanks each time. A request with blanks is called a frame.

The frame: "Write about ___ for ___. Keep it to ___."
Step 1 of 4
  1. The frame: "Write about ___ for ___. Keep it to ___."
  2. Fill the blanks: topic, reader, length.
  3. One call builds: "Write about the water cycle..."
  4. Same frame. New values each time.

Slide each blank below. One call builds the request.

Loading lab…

The rule

A saved request is a function. Its changing parts are parameters. One call assembles the whole request. Write it so other values can fill the blanks.

The frame with blanks is a function. Each blank is a parameter. A filled value is an argument.

`` function ask(topic, who, howLong) { let text = "Write about " + topic; text = text + " for " + who + ". Keep it to "; return text + howLong + "."; } ``

Here topic is the subject and who is the reader. howLong is the length.

Take ask("the water cycle", "Class 6", "half a page"). Line 2 makes text the words Write about the water cycle. Line 3 adds for Class 6. Keep it to after them. The return line adds half a page. and hands back the whole text.

So the call gives back one readable line:

Write about the water cycle for Class 6. Keep it to half a page.

The function must return the text. Only then can the calling line use it.

Try the lab to finish this lesson.