You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will make understanding easier for everyone, especially beginners to programming and the concepts.
This is from my experience, going through the cryptozombies curriculum the second time to revise all the concepts.
Original:
...
Declare a uint called counter and set it equal to 0. We'll use this variable to keep track of the index in our result array.
Declare a for loop that starts from uint i = 0 and goes up through i < zombies.length. This will iterate over every zombie in our array.
Inside the for loop, make an if statement that checks if zombieToOwner[i] is equal to _owner. This will compare the two addresses to see if we have a match.
Inside the if statement:
Add the zombie's ID to our result array by setting result[counter] equal to i.
Increment counter by 1 (see the for loop example above).
Suggested
...
Declare a uint called resultIndex and set it equal to 0. We'll use this variable to keep track of the index in our result array.
Declare a for loop that starts from uint zombieIndex = 0 and goes up through zombieIndex < zombies.length. We will use this variable to iterate over every zombie in our array.
Inside the for loop, make an if statement that checks if zombieToOwner[zombieIndex] is equal to _owner. This will compare the two addresses to see if we have a match.
Inside the if statement:
Add the zombie's ID to our result array by setting result[resultIndex] equal to zombieIndex.
Increment resultIndex by 1 (see the for loop example above).
Action
Would like to know your thoughts and feedback.
I can be the one making the changes and submitting the pull request.
Thanks.
The text was updated successfully, but these errors were encountered:
Summary
counter
toresultIndex
.i
tozombieIndex
.This will make understanding easier for everyone, especially beginners to programming and the concepts.
This is from my experience, going through the cryptozombies curriculum the second time to revise all the concepts.
Original:
...
uint
calledcounter
and set it equal to0
. We'll use this variable to keep track of the index in ourresult
array.for
loop that starts fromuint i = 0
and goes up throughi < zombies.length
. This will iterate over every zombie in our array.for
loop, make anif
statement that checks ifzombieToOwner[i]
is equal to_owner
. This will compare the two addresses to see if we have a match.if
statement:result
array by settingresult[counter]
equal toi
.counter
by 1 (see thefor
loop example above).Suggested
...
uint
calledresultIndex
and set it equal to0
. We'll use this variable to keep track of the index in ourresult
array.for
loop that starts fromuint zombieIndex = 0
and goes up throughzombieIndex < zombies.length
. We will use this variable to iterate over every zombie in our array.for
loop, make anif
statement that checks ifzombieToOwner[zombieIndex]
is equal to_owner
. This will compare the two addresses to see if we have a match.if
statement:result
array by settingresult[resultIndex]
equal tozombieIndex
.resultIndex
by 1 (see thefor
loop example above).Action
Thanks.
The text was updated successfully, but these errors were encountered: