Merge pull request #10903 from karuppiah7890/fix/NoteToAvoidSpaceAfterArray
Note to tell that spaces between array name and square brackets is not allowed.
This commit is contained in:
@ -1861,6 +1861,7 @@
|
||||
"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 <dfn>zero-based</dfn> indexing, so the first element in an array is element <code>0</code>.",
|
||||
"<strong>Example</strong>",
|
||||
"<blockquote>var array = [1,2,3];<br>array[0]; // equals 1<br>var data = array[1]; // equals 2</blockquote>",
|
||||
"<strong>Note</strong><br>There shouldn't be any spaces between the array name and the square brackets, like <code>array [0]</code>. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.",
|
||||
"<h4>Instructions</h4>",
|
||||
"Create a variable called <code>myData</code> and set it to equal the first value of <code>myArray</code> using bracket notation."
|
||||
],
|
||||
@ -1910,6 +1911,7 @@
|
||||
"Unlike strings, the entries of arrays are <dfn>mutable</dfn> and can be changed freely.",
|
||||
"<strong>Example</strong>",
|
||||
"<blockquote>var ourArray = [3,2,1];<br>ourArray[0] = 1; // equals [1,2,1]</blockquote>",
|
||||
"<strong>Note</strong><br>There shouldn't be any spaces between the array name and the square brackets, like <code>array [0]</code>. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.",
|
||||
"<h4>Instructions</h4>",
|
||||
"Modify the data stored at index <code>0</code> of <code>myArray</code> to a value of <code>3</code>."
|
||||
],
|
||||
@ -1958,6 +1960,7 @@
|
||||
"One way to think of a <dfn>multi-dimensional</dfn> array, is as an <em>array of arrays</em>. When you use brackets to access your array, the first set of brackets refers to the entries in the outer-most (the first level) array, and each additional pair of brackets refers to the next level of entries inside.",
|
||||
"<strong>Example</strong>",
|
||||
"<blockquote>var arr = [<br> [1,2,3],<br> [4,5,6],<br> [7,8,9],<br> [[10,11,12], 13, 14]<br>];<br>arr[3]; // equals [[10,11,12], 13, 14]<br>arr[3][0]; // equals [10,11,12]<br>arr[3][0][1]; // equals 11</blockquote>",
|
||||
"<strong>Note</strong><br>There shouldn't be any spaces between the array name and the square brackets, like <code>array [0][0]</code> and even this <code>array [0] [0]</code> is not allowed. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.",
|
||||
"<h4>Instructions</h4>",
|
||||
"Using bracket notation select an element from <code>myArray</code> such that <code>myData</code> is equal to <code>8</code>."
|
||||
],
|
||||
|
Reference in New Issue
Block a user