const solution = (s) => {
const midIndex =
s.length % 2 === 1
? Math.floor(s.length / 2)
: [s.length / 2 - 1, s.length / 2];
if (s.length % 2 === 1) {
return s.charAt(midIndex);
} else {
return s.charAt(midIndex[0]) + s.charAt(midIndex[1]);
}
};