function solution(d, budget) {
let max = 0;
let count = 0;
for (each of d.sort((a,b) => a-b)){
if(max + each <= budget){
max += each;
count++;
} else {
break;
}
}
return count;
}
function solution(d, budget) {
return ~(~d.sort((a,b)=>a-b).map(v => budget -= v).findIndex(v => v < 0) || ~d.length);
}