64 lines
1.1 KiB
Markdown
64 lines
1.1 KiB
Markdown
|
# headbands quiz
|
||
|
|
||
|
create a charades game with a collection of strings #offset #screen #variables #docs
|
||
|
|
||
|
## Name
|
||
|
|
||
|
## Directions
|
||
|
|
||
|
Use this activity document to guide your work in the [headbands tutorial](/microbit/lessons/headbands/tutorial).
|
||
|
|
||
|
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||
|
|
||
|
## 1. What is the meaning of the term 'collection' in programming? What is a 'collection' of strings?
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
## 2. Write the line of code that will display the string "puppy" using "data->coll".
|
||
|
|
||
|
```
|
||
|
coll = (<string[]>[])
|
||
|
coll.push("puppy")
|
||
|
coll.push("clock")
|
||
|
```
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
## 3. Write the line of code that will display the string "cat" using `"data->coll".
|
||
|
|
||
|
```
|
||
|
coll = (<string[]>[])
|
||
|
coll.push("puppy")
|
||
|
coll.push("clock")
|
||
|
coll.push("cat")
|
||
|
```
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
## 4. Write the five (5) lines of code that will add the following five words to `data->coll`: puppy, clock, night, cat, cow.
|
||
|
|
||
|
```
|
||
|
coll = (<string[]>[])
|
||
|
```
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
## 5. Write the code to get a string from the collection at a random position.
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|
||
|
<br/>
|
||
|
|