Question 13
Back to Exercise
A loop produces 10,000 lines of CSV. Which approach is clear and predictable?
- A Push each line into an array and call join("\n") once at the end Correct
- B Modify one character of the string at a time with str[i] = …
- C Create a new String object for each line
- D Use str.reverse() at the end
Correct Answer: Option A
Strings cannot be modified in place. Collecting parts and joining once is idiomatic (engines also optimise +=, but join keeps intent clear).
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!