
function solution(strings=[], n) {
// split()을 사용하여 배열로
//
strings.sort((a,b)=>{
if (a[n]> b[n])
return 1;
else if (a[n] <b[n])
return -1;
else{
if (a>b) {
return 1;
}
else{
return -1;
}
}
});
return strings;
}

function solution(food) {
let answer = [];
food.forEach((e,i) => {
if (i>0) {
let tmp = e %2 === 0? e: e-1;
for (let index = 0; index < Math.floor(tmp/2); index++) {
answer.push(i);
}
}
});
let temp = [...answer];
temp.reverse();
answer.push(0);
let result = answer.concat(temp);
return result.join('');
}