Skip to content

How do I fetch the length of the string

This example demonstrates how to calculate the length of the string.

In the solution shown below, the length of the string "Worksoft SaaS" is calculated using "length" javascript property in "storeEval" command and stored into a variable.

Solution:

# Command Target Value
Fetching the length of the string
1 storeEval
function strLength(){ var string = "Worksoft SaaS"; var length = string.length; return length; } strLength();stringLength
Print the result using echo
4 echo ${stringLength}  

Tips, Tricks, Gotchas & Best Practices:  

  • As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscores.
  • The variable name used in the 'Value' field of the Store command should not contain the following special characters which are not allowed: ​>, <, ==, !=, >=, <=, +, -, *, /, %, (, ).


Feedback and Knowledge Base