To create this array, we follow these steps:
1. Create an empty uint array
2. Then create a write function so that we can update the state of our array.
3. Then by using for loop, we will push values to the array.
4. The values that we will push to our array should be even numbers. So we will use modulus.
If the remainder of any number that is divided by 2 is not equal to 0, than those number are odd.
So, if you divide 5 by 2, the remainder is 1, then 5 is odd.
If you divide 6 by 2, the remainder is 0, then 6 is even.
5. Lastly we will create a view function, to see our array after each click.
6. You can copy-paste this to
Remix, and play with it to practice and learn.
Click on arrows for the next For loop & Array exercise: ⇨ ⇨