javascript

How to Reverse String using split() and reduce() in javascript

const text = "javascript";

const reversed = text.split("").reduce((acc, curr) => {
	console.log( curr + acc ); // j
    return curr + acc; // aj
	
	
}, "");

console.log(reversed);
// tpircsavaj 


let x = text.split("");
console.log( x ); // it return string array