- 23 May 2023
-
DarkLight
-
PDF
charAt
- Updated on 23 May 2023
-
DarkLight
-
PDF
charAt Task Purpose
The charAt task is used to get a character at a given index. The index of the first character in the string is "0", the second character is "1", and so on. When the index value is specified the return result will be the character at that index location in the string.
Potential Use Case
Suppose you have a long list of numbers and you want to verify that a certain number is indeed located at a certain space in the index. You could use the charAt task for that validation.
Properties
Input and output parameters are shown below.
Incoming | Type | Description |
---|---|---|
str |
String | Required. The string to get a character from. |
index |
Number | Required. The index to get the character at. |
Outgoing | Type | Description |
---|---|---|
character |
String | The single character at the specified index. |
Example
In this IAP example:
-
The
str
reference value is the two word sentence "Hello World". -
The
index
location is position "1" in thestr
. -
The result of this task will return the letter "e" because the
character
is located in the number "1" position of the index. Remember the index starts with "0" and counts up from there.