LearnFrenzy
Sign in Take a free test

String Methods · Predict the Output · Question 18

concat with non-strings Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 18 Back to Exercise

What does the following JavaScript code print (console output, as in Node.js)?

main.js
console.log("ab".concat("cd", 1, null, [2, 3]));
  • A abcd1null2,3 Correct
  • B abcd1
  • C abcd1null[2,3]
  • D TypeError
Correct Answer: Option A

concat converts each argument to a string: 1 → "1", null → "null", [2, 3] → "2,3".

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links