Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  178] [ 2]  / answers: 1 / hits: 47444  / 10 Years ago, thu, february 27, 2014, 12:00:00

Having a little trouble understanding what this does. If I have a string,



Using Mcdonalds as an example, I do:



McDonalds.split().reverse().join();


What exactly am I doing?



Am I splitting each character (M c D o n a l d s), then reversing it (s d l a n o D c M) then joining to get (sdlanoDcM)? (Trying to see if I understand this right)


More From » join

 Answers
4

Make sure you specify an empty string to .join, otherwise you'll get commas between each character:



McDonalds.split().reverse().join(); // sdlanoDcM

[#72261] Wednesday, February 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
antonb

Total Points: 424
Total Questions: 104
Total Answers: 101

Location: Serbia
Member since Tue, Jul 26, 2022
2 Years ago
;