How can I run a method stored in a variable?
For example, there is a dropdown of available methods and the selects a method that the user wants it to complete. That method is stored in the variable, userSelectedMethod. For the example, that method would be toUpperCase().
var userSelectedMethod = "toUpperCase()"
I want the script to run the method that is in the variable and apply it to the enteredText variable.
I tried using the following code. (Didn't work, obviously)
/// Attempt 1
var newResult = enteredText.userSelectedMethod;
/// Attempt 2
var newResult = enteredText.Module[userSelectedMethod];
/// Attempt 3
var newResult = enteredText.callback(userSelectedMethod);
I want the newResult to run whatever method the user's selected method is. What would be the proper and simplest method of accomplishing this?
Note: The variable names and extra steps that I had in my project, from which this question arose, have been removed and simplified to explain what I'm trying to do.