Implement string and set operations on the lists.

Copy a string

In JavaScript, the individual characters in a string can be accessed but not assigned or modified. The following program copies a string to another string:

Press + to interact

String concatenation

Concatenation means appending a string to another string. The following program concatenates two strings and stores them to another string:

Search a string in an array of strings

The following program checks whether a string or character is present in a string element.

Sample input

  • First parameter: array

    p = ['25','55','888','9','30','45']
    
  • Second parameter: string

    '5'
    

Sample output 1

 5 is found at index 0

 5 is found at index 1

 5 is found at index 5
  • Second parameter: string
    '50'
    

Sample output 2

50 is NOT FOUND in the array

Reverse a string

The following program stores the reverse of a string to another string.

Sample input

'was it a car or a cat I saw'

Sample output

ORIGINAL string is: 'was it a car or a cat i saw'
REVERSED string is: 'was i tac a ro rac a ti saw'

Get hands-on with 1400+ tech skills courses.