indexes
.
Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array. Like strings, arrays use zero-based indexing, so the first element in an array is element 0
.
array [0]
. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.
myData
and set it to equal the first value of myArray
using bracket notation.
myData
should equal the first value of myArray
.
testString: assert((function(){if(typeof myArray !== 'undefined' && typeof myData !== 'undefined' && myArray[0] === myData){return true;}else{return false;}})(), 'The variable myData
should equal the first value of myArray
.');
- text: The data in variable myArray
should be accessed using bracket notation.
testString: assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), 'The data in variable myArray
should be accessed using bracket notation.');
```