🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Welcome to JavaScript String Quiz. This JavaScript String Quiz features 15+ multiple-choice questions designed to test your knowledge of JavaScript String and methods. After each question, we'll provide the correct answer along with an explanation to ensure you grasp the concepts. Ready to start? Let's dive in!
1. How do you declare a string variable in JavaScript?
let str = 'Hello';
var str = "Hello";
const str = 'Hello';
Answer:
Explanation:
2. What will be the length of the following string?
let myString = "Hello, World!";
Answer:
Explanation:
3. Which method is used to convert a string to all lowercase letters?
Answer:
Explanation:
4. Which method is used to remove leading and trailing whitespace from a string?
Answer:
Explanation:
5. What will be the output of the following code?
'JavaScript'.charAt(0)
Answer:
Explanation:
6. What will 'hello'.concat(' world') return?
Answer:
Explanation:
7. What will 'JavaScript'.endsWith('script') return?
Answer:
Explanation:
8. What is the result of 'JavaScript'.indexOf('Script')?
Answer:
Explanation:
9. What will 'JavaScript'.lastIndexOf('a') return?
Answer:
Explanation:
The lastIndexOf() method in JavaScript returns the last occurrence of a specified value in a string. The string is searched from the end to the beginning, but returns the index from the beginning, at position 0. If we apply this method to 'JavaScript'.lastIndexOf('a'), the output will be 3. This is because the last occurrence of 'a' in 'JavaScript' is at index 3 (remember, JavaScript uses 0-based indexing).
10. What is the output of 'hello'.replace('l', 'r')?
Answer:
Explanation:
11. What will 'JavaScript'.slice(4, 10) return?
Answer:
Explanation:
12. What will 'JavaScript'.split('') return?
Answer:
Explanation:
13. What is the output of 'JavaScript'.startsWith('Java')?
Answer:
Explanation:
14. What is the output of 'JavaScript'.substring(4)?
Answer:
Explanation:
15. What method do you use to join all elements of an array into a single string?
Answer:
Explanation:
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment