I'm a beginner to learn JavaScript. I tried to run this code below, but I got the error "expected undefined to equal 'es'". How can I fix it?
function getMiddle(character)
{
const chrArr = character.split('');
if(chrArr.length % 2 == 0) {
let middleChr1 = Math.floor((chrArr.length - 1) / 2);
console.log(`"${chrArr[middleChr1]}${chrArr[middleChr1 + 1]}"`);
}else{
let middleChr2 = Math.floor(chrArr.length / 2);
console.log(`"${chrArr[middleChr2]}"`);
}
}