Reverse a String help me understand the .split()

Tell us what’s happening:
so i got to the answer and ive been tinkering with the .split() and the .join() but i cant quite figure out why (or how many) spaces are needed in .split()

this piece of code works with .split(’ ‘) while another piece of code a few lessons later works with .split(’ ')


Your code so far

function reverseString(str) {
  return str.split('').reverse().join(' ');


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

This fails, not because of your split but because of your join. Don’t add spaces in the join.

For split you are telling it what string to use as the divider. If you give and empty string, it divides on every character.

For join, you are telling it what to add in between the joined strings. We don’t want anything added inbetween, we send an empty string.

as i said i already got to the answer and have been tinkering with the code…passing the lessons are not the problem but understanding how and why i passed them is becoming increasingly harder

Sorry, I responded because you posted a non-working solution.

As to understanding getting harder - yeah, this is hard stuff. It’s going to get harder. But if you keep at it, you can get it. My first stop whenever I’m not sure how some JS works is the MDN docs. If you google “mdn split”, it will take you there. There are too many things to memorize and they keep changing so being able to google things and find the information is an important skill.