Skip to content

Instantly share code, notes, and snippets.

@vmwarecode
Created February 22, 2017 21:32
Show Gist options
  • Save vmwarecode/f066acc50e633391a9989ee935f246c1 to your computer and use it in GitHub Desktop.
Save vmwarecode/f066acc50e633391a9989ee935f246c1 to your computer and use it in GitHub Desktop.
Remove string from array of strings by value
// VMware vRealize Orchestrator action sample
//
// Removes a string from an array of strings by value.
// Does not account for duplicate values in the array.
//
//Action Inputs:
// aStrings - Array/String
// toRemove - String
//
//Return type: Array/String
//find and remove 'toRemove' in the 'aStrings' array
var foundAt = null;
for (var i = 0; i < aStrings.length; i++) {
if (aStrings[i] == toRemove) {
foundAt = i;
break;
}
}
if (foundAt != null) {
aStrings.splice(foundAt,1);
}
return aStrings;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment