Question 20
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log(" Hello World From LF ".trim().toLowerCase().split(" ").join("-"));
- A Hello-World-From-LF
- B hello-world-from-lf Correct
- C -hello-world-from-lf-
- D hello world from lf
Correct Answer: Option B
Each method returns a new string (or array) that the next method works on: trim, lower-case, split into words, join with hyphens.
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!