Exercise - Demonstrate your knowledge of arrays.
ArraysExercise
. It contains an array called numbers
that is initialized with the numbers 1–10. Copy and paste this into your file.
getNumbers
that returns the entire numbers
array.
public
function called resetNumbers
that resets the numbers
array to its initial value, holding the numbers from 1-10.
.push()
is more gas-efficient!public
function! You’ll learn how to protect functionality in another lesson.appendToNumbers
that takes a uint[] calldata
array called _toAppend
, and adds that array to the storage
array called numbers
, already present in the starter.
address
array called senders
and a uint
array called timestamps
.
Write a function called saveTimestamp
that takes a uint
called _unixTimestamp
as an argument. When called, it should add the address of the caller to the end of senders
and the _unixTimestamp
to timestamps
.
afterY2K
that takes no arguments. When called, it should return two arrays.
The first should return all timestamps that are more recent than January 1, 2000, 12:00am. To save you a click, the Unix timestamp for this date and time is 946702800
.
The second should return a list of senders
addresses corresponding to those timestamps.
public
functions called resetSenders
and resetTimestamps
that reset those storage variables.