"a"
from ourArray
and assign it to a variable, we can do so with the following code:
```js
let ourVariable = ourArray[0];
// ourVariable equals "a"
```
In addition to accessing the value associated with an index, you can also set an index to a value using the same notation:
```
ourArray[1] = "not b anymore";
// ourArray now equals ["a", "not b anymore", "c"];
```
Using bracket notation, we have now reset the item at index 1 from "b"
, to "not b anymore"
.
1
) of myArray
to anything you want, besides "b"
.
myArray[0]
is equal to "a"
testString: assert.strictEqual(myArray[0], "a", 'myArray[0]
is equal to "a"
');
- text: myArray[1]
is no longer set to "b"
testString: assert.notStrictEqual(myArray[1], "b", 'myArray[1]
is no longer set to "b"
');
- text: myArray[2]
is equal to "c"
testString: assert.strictEqual(myArray[2], "c", 'myArray[2]
is equal to "c"
');
- text: myArray[3]
is equal to "d"
testString: assert.strictEqual(myArray[3], "d", 'myArray[3]
is equal to "d"
');
```