Fix example code on filter method to avoid confusion

pull/18182/head
Eric Leung 2015-11-26 18:02:37 -08:00
parent a24e76675a
commit 7b69f5f648
1 changed files with 2 additions and 2 deletions

View File

@ -322,10 +322,10 @@
"The <code>filter</code> method is used to iterate through an array and filter out elements where a given condition is not true.",
"<code>filter</code> is passed a callback function which takes the current value (we've called that <code>val</code>) as an argument.",
"Any array element for which the callback returns true will be kept and elements that return false will be filtered out.",
"The following code is an example of using filter to remove array elements that are not even numbers:",
"The following code is an example of using <code>filter</code> to remove array elements that are equal to five:",
"Note: We omit the second and third arguments since we only need the value",
"<code>array = array.filter(function(val) {</code>",
"<code>&nbsp;&nbsp;return val % 2 === 0;</code>",
"<code>&nbsp;&nbsp;return val !== 5;</code>",
"<code>});</code>",
"Use <code>filter</code> to remove all elements from <code>array</code> that are greater than 5."
],