Skip to content

Latest commit

 

History

History
115 lines (76 loc) · 1.75 KB

09-string-exercise.md

File metadata and controls

115 lines (76 loc) · 1.75 KB

Exercise-09

Question 1

const str = "My name is learn javascript";

Split this string using space and find length.

Question 2

Write a program to check if a string is palindrome or not?

Question 3

9581444444 Convert to below

95814*****
*****44444
958**444**

Question 4

Write a program to reverse a string. For example:

Hello -> olleH
Bye -> eyB

Question 5

Captialize first character of the String. For example:

learnjavascript -> Learnjavascript
hello -> Hello

Question 6

In a string convert uppercase character to lowercase and vice versa.

HeLlo -> hElLO
leArNjavaScript -> LEaRnJAVAsCRIPT

Question 7

Camelize the string. for example:

Hello World -> helloWorld
my name is Sajid -> myNameIsSajid
learn javascript -> learnJavascript

Question 8

Count number of spaces in a string.

Question 9

Print below pattern using repeat function:

1111111111
222222222
33333333
4444444
555555
66666
7777
888
99
0

Question 10

"My name is Sajid Khan", take input from user and print whatever is there after the word. For example:

Hello learn javascript
input: "rn"
output: javascipt

Question 11

Write differences between substring vs slice vs substr methods.

Question 12

What is Regex ? Give examples.

Question 13

Write difference between match vs search functions.

Question 14

Take a sentence using prompt box. In next question ask for a string and check if that string is present in that sentence or not.

Question 15

Take a string and if in that string anything is there other than the characters $, _, number, a-z, A_Z then remove them from the string. Do it with regex and without regex. for example:

We%^%$Cod!@#e -> We$Code