Three Subjects were covered from JavaScript, from document. Numbered and listed below as per document. Numbers in Markdown are continious, actual numbers are 9, 11 and 13.
-
JavaScript Strings:
• Task 1: Write a script that creates a string object and uses different string methods (e.g., length, toUpperCase, indexOf). Log the results..
• Task 2: Create a script that takes a sentence as input and reverses the string using JavaScript string methods.
• Task 3: Implement a function that checks if a given substring is present within a string and returns the index of its first occurrence.
• Task 4: Write a script that compares two strings and logs whether they are equal or not. If not, log the differences.
-
DOM Manipulation:
• Task 1: Write a script that selects an HTML element by its ID and changes its content to "Hello, World!" using JavaScript.
• Task 2: Create a script that changes the background color of an HTML element when the user clicks a button.
• Task 3: Implement a script that adds a new list item to an unordered list every time a button is clicked.
• Task 4: Write a script that animates an HTML element by gradually changing its position on the page using setInterval.
-
Regular Expressions:
• Task 1: Write a regular expression that matches valid email addresses. Test it against a list of strings and display which ones are valid.
• Task 2: Create a script that uses a regular expression to find all instances of a specific word in a sentence and replaces them with another word.
• Task 3: Write a regular expression to validate a phone number format (e.g., (123) 456-7890). Test the regular expression on different inputs.
• Task 4: Implement a script that checks if a string contains only alphanumeric characters using a regular expression.