Question 7
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("".split(","), "".split(""), "".split(",").length);
- A [ '' ] [] 1 Correct
- B [] [] 0
- C [ '' ] [ '' ] 1
- D [] [ '' ] 0
Correct Answer: Option A
Splitting "" on a separator gives one empty piece (a common bug when counting CSV fields); splitting it into characters gives an empty array.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!