function reverseString(str) {
    // [...str] converts str to an array ["1", "2", "3"]
    // accumulator starts as '', so when adding char + acc, it will concat the string
    // because char + acc, it is reversing the string
    // acc = '', char = 1 => char + acc == '1'
    // acc = '1', char = 2 => char + acc == '21'
    // acc = '21', char = 3 => char + acc == '321'
    return [...str].reduce((acc, char) => char + acc, '');
    }
/* A quick recap of how reduce is working */
A quick recap of how reduce is working
A quick recap of how reduce is working
function reverseString(str) {
    return [...str].reduce((acc, char) => char + acc, '');
    }
function reverseString ( str ) { return [ ... str ] . reduce ( ( acc , char ) => char + acc , '' ) ; }
A quick recap of how reduce is working
A quick recap of how reduce is working
// [...str] converts str to an array ["1", "2", "3"] // accumulator starts as '', so when adding char + acc, it will concat the string // because char + acc, it is reversing the string // acc = '', char = 1 => char + acc == '1' // acc = '1', char = 2 => char + acc == '21' // acc = '21', char = 3 => char + acc == '321'