Why does this print statement have commas in it?

So I wrote:

function reverseString(str) {
  var str2 = []; 
  for (var i=0; i<str.length; i++) {
  str = str2.toString();
  return str;


I thought str2.join("") got rid of the commas.

It does, but it returns a string. I don’t see where you are capturing this returned string.

Then how come when I print out str2 it prints out an array?

you are not capturing the returned string, join returns a string, but you are not doing anything with the returned value

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.