charAt
  • 23 May 2023
  • Dark
    Light
  • PDF

charAt

  • Dark
    Light
  • PDF

Article summary

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 the str.

    charAt-ex01

  • 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.

    charAt-ex02


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.