0% found this document useful (0 votes)
19 views2 pages

JS String Practice Questions WebDev

This document provides a comprehensive list of JavaScript string practice questions focused on web development. It covers basic usage, validation tasks, string transformation, and real-world mini tasks. Each section includes practical exercises aimed at improving string manipulation skills for web applications.

Uploaded by

abhaykumardev001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

JS String Practice Questions WebDev

This document provides a comprehensive list of JavaScript string practice questions focused on web development. It covers basic usage, validation tasks, string transformation, and real-world mini tasks. Each section includes practical exercises aimed at improving string manipulation skills for web applications.

Uploaded by

abhaykumardev001
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript String Practice Questions for Web Development

Basic Usage (Form, Input, Display):

1. Get the value from a form input and trim extra spaces.
2. Capitalize the first letter of a user's name before displaying.
3. Convert a paragraph of text to all lowercase before saving it.
4. Show only the first 100 characters of a string followed by "... Read More".
5. Create a function to check if a password is at least 8 characters and contains a number.
6. Convert an email input to lowercase before validation.
7. Extract the domain name from an email.
8. Check if a string (like a search input) includes a keyword.
9. Replace all double spaces in a string with a single space.
10. Limit a string's length to n characters and add ellipsis if it exceeds.

Validation Tasks (Common in Forms):

1. Check if an input is a valid email using regex.


2. Check if a string contains only numbers (for phone number input).
3. Check if a string contains only letters (for name input).
4. Validate if a username contains no special characters.
5. Remove all symbols except @ and . from an email input.
6. Check if two password fields match before submitting the form.
7. Ensure a URL starts with http:// or [Link]
8. Write a function to detect if a string contains HTML tags (basic regex).
9. Validate that a credit card input has only 16 digits (no spaces or dashes).
10. Extract the text content from a HTML-like string (e.g., <div>Hello</div> -> Hello).

Transforming / Formatting Strings:

1. Convert "hello_world-user" to "Hello World User".


2. Transform a kebab-case string (e.g., "background-color") to camelCase.
3. Convert camelCase to normal space-separated words.
4. Make the first letter of every word uppercase (title case).
5. Add zero padding to numbers (e.g., "7" -> "07").
6. Format a phone number like 1234567890 -> 123-456-7890.
7. Remove all non-ASCII characters from a string.
8. Extract all hashtags from a post string (like "Hello #World #JS").
9. Remove HTML entities from a string (e.g., &amp; -> &).
10. Replace all line breaks (\n) in a string with <br> tags for display.

Real-World Mini Tasks / Challenges:

1. Highlight search keyword in a sentence (e.g., turn "js" in "Learn js today" to <mark>js</mark>).
2. Parse and format a CSV string (e.g., "name,age\nJohn,30" -> array of objects).
3. Convert a textarea input (multi-line string) into an array of lines.
4. Build a tag system from comma-separated user input.
5. Create a slug from a title (e.g., "Hello World!" -> "hello-world").
6. Build a function that removes emoji from user comments.
7. Convert YouTube video links to embeddable iframe format.
8. Escape special HTML characters to display them as text (< -> &lt;, etc.).
9. Count the number of words typed into a form (live word counter).
10. Detect if a pasted text is copied from Microsoft Word (e.g., contains mso- styles).

You might also like