솔루션
const solution = (my_string) => {
const nums = my_string.match(/[0-9]+/g);
const answer = nums ? nums.map((num) => +num).reduce((a, c) => a + c, 0) : 0;
console.log(answer);
return answer;
};
솔루션
function solution(my_string) {
const answer = my_string.split(/\D+/).reduce((acc, cur) => acc + Number(cur), 0);
console.log(answer);
return answer;
}
솔루션
function solution(n) {
let answer = ""
for(let i = 0 ; i<n.length; i++){
if(Number.isInteger(+n[i])){
answer += n[i]
}else{
answer += " "
}
}
console.log(answer);
return answer.split(" ").reduce((acc,cur)=> acc += +cur,0)
}