Created
February 22, 2017 21:32
-
-
Save vmwarecode/f066acc50e633391a9989ee935f246c1 to your computer and use it in GitHub Desktop.
Remove string from array of strings by value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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