function solution(people, limit) {
var answer = 0;
people.sort((a,b) => a-b)
let boat = []
while (people.length) {
boat.push(people.pop())
answer++
if (boat[0] + people[0] <= limit) people.shift()
boat = []
}
return answer;
}
function solution(people, limit) {
people.sort(function(a, b){return a-b});
let i=0
for(i=i, j=people.length-1; i < j; j--) {
if( people[i] + people[j] <= limit ) i++;
}
return people.length-i;
}