// 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 10: | Line 10: | ||
JavaScript= | JavaScript= | ||
<syntaxhighlight lang="JavaScript"> | <syntaxhighlight lang="JavaScript"> | ||
// ForEach Example | // ForEach Example | ||
Revision as of 12:35, 4 August 2024
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