Arrays Work
Activity
Go to Activity: Arrays Intro. Complete student tasks 1-2.
Tasks
Task 1
- Add two more numbers to the array, by pressing theβ―+β―button on the block.
- Change theβ―get value atβ―block to choose a random index between 0 and 3.
- Add another number to the array.
- Comment your code.
Shared project link:
Task 1 Challenge
Modify your code to randomly splash any new values added to the array.
Shared project link:
Task 2
- Create a new project called addingToAnArrayEvent.
- Create a new array with the values -3, 3, and 4.
- Create an on A button press event that adds a random number between -10 and 10 to the array.
- Create an on B button press event that selects a random item from the list and splash it.
- Comment your code.
Shared project link:
Task 2 Challenge
Modify the value of the splash to display the result of adding two random values from the list.
Shared project link:
Extension
Use JavaScript or Python to create the project above.
Shared project link:
Apply
Incorporate these concepts into an existing project.
Shared project link:
Reflection/Homework
What is the difference between creating an array of numbers and storing multiple values as individual variables (as in, value1 = 1, value2 = 2, value3 ...)?
What can an array do that storing different variables by themselves cannot?
How does the length of an array relate to the position of the final element?