Quiz String Methods
I have research, shortlist and designed this quiz according to JavaScript strings and string methods for all the learners of devscall.
1.
How do you define a string in JavaScript?
2.
What does the following output?
javascript
1 2
let message = "It's a sunny day!"; console.log(message);
3.
What is the output of this code?
javascript
1 2
let text = "JavaScript"; console.log(text.length);
4.
What will be the result of this code?
javascript
1 2
let text = "JavaScript"; console.log(text.charAt(2));
5.
What does the following code return?
javascript
1 2 3
let name = "Alice"; let greeting = `Hello, ${name}!`; console.log(greeting);
6.
What will be the result of this code?
javascript
1 2 3
let text = "JavaScript is fun"; let part = text.slice(0, 10); console.log(part);
7.
Which method splits a string into an array based on a separator?