I’m new to Javascript, I want to reverse a string, I have two types one is from dlrow olleh to hello world and the other one is world hello to hello world I couldn’t try please help me
>Solution :
I would try this
console.log(rw('t1', 'dlrow olleh'))
console.log(rw('t2', 'world hello'))
function rw(type, val) {
if (type == "t1") return val.split('').reverse().join("");
else if (type == "t2") return val.split(' ').reverse().join(" ");
}