After some tries only one of this fonction gave me the right result in CodeWars. Can any one explain to me the reason please?
{
//1. solution => wrong
var middle = Math.round(s.length / 2);
s.length % 2 == 0 ? console.log(s[middle-1] + s[middle]) : console.log(s[middle-1]);
//2. solution => correct
return (s.length%2 == 0 ? s.substr((s.length/2-1),2) : s.substr((s.length/2),1));
}
