<pre>
// ForEach Example
var School;
School = new Array("Principal", "Mr. Garrison", "Chef");
School.forEach(listItem)
function listItem(item){
NSB.Print(item);
}
ForEach: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 5: | Line 5: | ||
ForEach calls ''function'' on each element of ''array''. | ForEach calls ''function'' on each element of ''array''. | ||
== Example | == Example == | ||
< | <tabber> | ||
JavaScript= | |||
<syntaxhighlight lang="JavaScript"> | |||
<pre> | <pre> | ||
// ForEach Example | // ForEach Example | ||
Line 28: | Line 19: | ||
function listItem(item){ | function listItem(item){ | ||
NSB.Print(item); | NSB.Print(item); | ||
} | }</syntaxhighlight> | ||
</ | |-| | ||
BASIC= | |||
<syntaxhighlight lang="vb.net"> | |||
Rem ForEach Example | |||
Dim School | |||
School = Array("Principal", "Mr. Garrison", "Chef") | |||
ForEach(School, listItem) | |||
Function listItem(item) | |||
Print item | |||
Next</syntaxhighlight> | |||
</tabber> | |||
== Output == | == Output == |
Revision as of 17:55, 22 July 2019
ForEach(array, function)
Description
ForEach calls function on each element of array.
Example
Rem ForEach Example
Dim School
School = Array("Principal", "Mr. Garrison", "Chef")
ForEach(School, listItem)
Function listItem(item)
Print item
Next
Output
Principal Mr. Garrison Chef