This function iterates over every character in the string and executes the callback function to reduce the string to a single value.
stringReduce(string,callback,initialValue)
returns string
string.reduce(callback, initialValue)
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| string | string | Yes | Original input string. | |
| callback | any | Yes | Closure or a function reference. | |
| initialVal | any | No | Initial value for the reduce operation. |
Reduce the string to a single value.
letters="abcdef";
closure=function(inp1,inp2){return inp1 & inp2;}
writeOutput( StringReduce(letters,closure,"z") );
Reduce the string to a single value.
letters="abcdef";
closure=function(inp1,inp2){return inp1 & inp2;}
writeOutput( letters.reduce(closure,"z") );