https://programmers.co.kr/learn/courses/30/lessons/70129
function solution(s) {
let result = [];
let count = 0, zero = 0;
let notZero = [];
while(s != 1) {
s.split("").map(num => num != 0 ? notZero.push(num) : zero++);
s = notZero.length.toString(2);
count++;
notZero = [];
}
result.push(count, zero);
return result;
}
// 다른 분의 풀이
function solution(s) {
var answer = [0,0];
while(s.length > 1) {
answer[0]++;
answer[1] += (s.match(/0/g)||[]).length;
s = s.replace(/0/g, '').length.toString(2);
}
return answer;
}