Merge pull request #13068 from Greenheart/fix/array-splice-formatting
fix(challenge): formatting of "Remove Items Using splice()".
This commit is contained in:
commit
f80b02b342
@ -176,7 +176,7 @@
|
||||
"id": "587d78b2367417b2b2512b10",
|
||||
"title": "Remove Items Using splice()",
|
||||
"description": [
|
||||
"Ok, so we've learned how to remove elements from the beginning and end of arrays using <code>pop()</code> and <code>shift()</code>, but what if we want to remove an element from somewhere in the middle? Or remove more than one element at once? Well, that's where <code>splice()</code> comes in. <code>splice()</code> allows us to do just that: <strong>remove any number of consecutive elements</strong> from anywhere on an array.",
|
||||
"Ok, so we've learned how to remove elements from the beginning and end of arrays using <code>shift()</code> and <code>pop()</code>, but what if we want to remove an element from somewhere in the middle? Or remove more than one element at once? Well, that's where <code>splice()</code> comes in. <code>splice()</code> allows us to do just that: <strong>remove any number of consecutive elements</strong> from anywhere in an array.",
|
||||
"<code>splice()</code> can take up to 3 parameters, but for now, we'll focus on just the first 2. The first two parameters of <code>splice()</code> are integers which represent indexes, or positions, of the array that <code>splice()</code> is being called upon. And remember, arrays are <em>zero-indexed</em>, so to indicate the first element of an array, we would use <code>0</code>. <code>splice()</code>'s first parameter represents the index on the array from which to begin removing elements, while the second parameter indicates the number of elements to delete. For example:",
|
||||
"<blockquote>let array = ['today', 'was', 'not', 'so', 'great'];<br><br>array.splice(2, 2);<br>// remove 2 elements beginning with the 3rd element<br>// array now equals ['today', 'was', 'great']</blockquote>",
|
||||
"<code>splice()</code> not only modifies the array it's being called on, but it also returns a new array containing the value of the removed elements:",
|
||||
@ -187,7 +187,7 @@
|
||||
"challengeSeed": [
|
||||
"function sumOfTen(arr) {",
|
||||
" // change code below this line",
|
||||
"",
|
||||
" ",
|
||||
" // change code above this line",
|
||||
" return arr.reduce((a, b) => a + b);",
|
||||
"}",
|
||||
|
Loading…
x
Reference in New Issue
Block a user