6.
What is the output of the following code?
const sentence = "I love JavaScript";
const words = sentence.split(" ");
console.log(words);
["I love", "JavaScript"]
["I love JavaScript"]
["I", "love", "JavaScript,"]
["I", "love", "JavaScript"]
Correct: D
The split() method splits a string into an array of substrings based on the specified separator. In this case, the separator is a space " ". So the given sentence "I love JavaScript" will be split at each space, resulting in an array with the words ["I", "love", "JavaScript"].