I want to write a function to test if a string such as "(())" or "<<>>" is equal on both sides if they were reversed. where as something like "((()" would be false
Is there a name for something like this? I assume is a common algorithm.
For some reason, reverse doesn't do anything on right after splitting it into an array?
function ifEqual(str) {
let left = str.slice(0, str.length / 2);
let right = str.slice(str.length / 2).split("").reverse().join("");
console.log(left);
console.log(right);
return left === right;
}
ifEqual("(())")