JavaScript String Questions
JavaScript String Questions
You are given a string S, and your task is to return an array B(having a size of 2), where B[0] contains the count of
character A (uppercase) in string S and B[1] contains the count of character D (uppercase) in string S.
Note: You have to complete countCharacters function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Constraints
1≤|S|≤100, where |S| denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input
AbaDd
Sample Output
11
Input Format
The first and the only line of the input contains a string S (with no space and contains only lowercase letters).
Output Format
Return updated String S as output, where the string contains the charcter followed by their occurrence (if greater than 1) in
alphabetical order.
Constraints
1≤|S|≤100, where |S| denotes the length of string S. S contains only lowercase alphabets.
Example
Sample Input
prepbytes
Sample Output
e2p2
Q3. Count the Vowels
You are given a string S containing both uppercase and lowercase letters. You need to find out the number of vowels in the
given string.
Note: You have to complete Count_Vowel function. No need to take any input.
Input Format
Output Format
Constraints
Example
Sample Input
Prepbytes
Sample Output
2
You are given two strings S1 and S2 (containing both uppercase and lowercase letters), You need to retrun a string which is the
concatenation of both the given strings.
Note: You have to complete Concatenate_Strings function. No need to take any input.
Input Format
The first line of the input contains the first string S1 and the second line of input contains the second string S2.
Output Format
Return the String S3 as output, which is the concatenation of given both strings.
Constraints
Example
Sample Input
Prep bytes
Sample Output
Prepbytes
You are given a string S, and your task is to return the length of the string S.
Note: You have to solve it without using length method. You have to complete findLength function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Return the length of the string S.
Constraints
1≤|S||≤100, where |S| denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input
CeDqe
Sample Output
5
You are given a string S consisting of two letters A and D,where each character represent the winner of N games played between Aditya
and Danish, where letter A represents the win of Aditya and letter D represents the win of Danish. You need to find out the that which
player wins the maximum number of games or there is a draw between them.
Note: You have to complete Game_Winner function. No need to take any input.
Input Format
Output Format
Return the name of the player who have won the maximum number of games, if both player won same number of games return Draw.
Constraints
Example
Sample Input 1
ADDAAADDDDD
Sample Output 1
Danish
Sample Input 2
ADDAAADD
Sample Output 2
Draw
You are given two strings S and P, and your task is to concatenate them and return the concatenated string.
Note: You have to complete joinStrings function. No need to take any input.
Input Format
The first and the only line of the input contains two space-separated strings S and P.
Output Format
Return the final concatenated string.
Constraints
1≤|S|,|P|≤100, where |S|and |P| denote the length of string S and P, respectively. S and P contain both lowercase and uppercase
alphabets.
Example
Sample Input
PrepBytes Technologies
Sample Output
PrepBytesTechnologies
You are given a string S, Your task is to check wether the given string is a Palindrome or not.
A Palindrome is a string, which turnout same when read in reverse direction. Example: "naman" is a Palindrome. String can contain
both upppercase lowercase letters.
Note: You have to complete Plain_Check function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Return "True" if the given string is Palindrome else return "False" (without " ") .
Constraints
1≤|S|≤100, where |S| denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input 1
Naman
Sample Output 1
False
Sample Input 2
naman
Sample Output 2
True
You are given a string S, Your task is to Reverse the string. String can contain both upppercase lowercase letters. Note: You have to
complete Reverse_String function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Return the reversed String.
Constraints
1≤|S|≤100, where |S| denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input
I am utkarsh raj
Sample Output
jar hsraktu ma I
You are given two strings S1 and S2, Your task is to print YES if both strings are same else print NO.
Note: You have to complete String_Match function. No need to take any input.
Input Format
The first line of the input contains a string S1. The second line of the input contains a string S2.
Output Format
Constraints
1≤|S1|,|S2|≤100, where |S| denotes the length of string S. S1 and S2 contains both lowercase and uppercase alphabets.
Example
Sample Input
Prepbytes Prepbytes
Sample Output
YES
You are given a string S, along with a pattern string and a text string. You need to repalce the pattern string in S to the text string.
Note: You have to complete Replace function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Constraints
1≤|S|≤100, where |S| denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input
Hi, I am You. You Prepbytes
Sample Output
Hi, I am Prepbytes.
You are given a string S, Your task is to split the string with respect to spaces.
Note: You have to complete Split_the_String function. No need to take any input.
Input Format
The first and the only line of the input contains a string S.
Output Format
Constraints
1≤|S|≤100, where |S|denotes the length of string S. S contains both lowercase and uppercase alphabets.
Example
Sample Input
I am utkarsh raj
Sample Output
I
am
utkarsh
raj
You are given a string S containing both uppercase and lowercase letters. You need to find out the number of vowels and the number of
consonants in the given string.
Note: You have to complete Count_Vowels function and Count_Consonants function. No need to take any input.
Input Format
Output Format
Return the number of Vowels and the number of Consonants in the string S in the functions.
Constraints
Example
Sample Input
Prepbytes
Sample Output
27