Arrays are very useful, but they're nowhere near as useful as they would be if you could change them. So, here is how you change the values in arrays:
To access a certain object in an array, you type:
<arrayName>[no];
where 'arrayName' is the name of the array that you are changing, and 'no' is the number that defines what thing you are changing.
Array numbers work as follows:
take the following: let arr = ['elephant', 'ostrich', 'tiger', 'penguin'];
Then elephant is number 0
Ostrich is number 1
Tiger is Number 2
And so on.
It is important that you remember that arrays start on 0 and not 1.
Arrays also have a lot of different functions that can be called on them, for which the documentation can be found here.
NOTE: For now, alot of that might not make 100% sense, but as you continue to read these tutorials you will understand them more and more.
CHALLENGE: Take your answer from the previous challenge and change the last animal to 'alpaca' using code.
If you have any questions, let me know in the comment section.
- Noah
To access a certain object in an array, you type:
<arrayName>[no];
where 'arrayName' is the name of the array that you are changing, and 'no' is the number that defines what thing you are changing.
Array numbers work as follows:
take the following: let arr = ['elephant', 'ostrich', 'tiger', 'penguin'];
Then elephant is number 0
Ostrich is number 1
Tiger is Number 2
And so on.
It is important that you remember that arrays start on 0 and not 1.
Arrays also have a lot of different functions that can be called on them, for which the documentation can be found here.
NOTE: For now, alot of that might not make 100% sense, but as you continue to read these tutorials you will understand them more and more.
CHALLENGE: Take your answer from the previous challenge and change the last animal to 'alpaca' using code.
If you have any questions, let me know in the comment section.
- Noah
Comments
Post a Comment