Extract Numbers

Problem

Given a string with a mixture of letters and numbers, only the numbers are extracted and a natural number is created in that order.
If you extract only numbers from “tge0a1h205er”, it is 0, 1, 2, 0, 5, and if you make a natural number from this, it becomes 1205.
The natural number produced by extraction does not exceed 100,000,000.

input

The first line is given a string of numbers shuffled. The length of the string cannot exceed 50.

g0en2T0s8eSoft

output

Prints a natural number on the first line.

208

Solution

using isNaN()

function solution(str) {
	let answer = '';
	for (let x of str) {
		if (!Number.isNaN(parseInt(x))) answer += x;
	}
	return parseInt(answer);
}
function solution(str) {
	let answer = '';
	for (let x of str) {
		if (!isNaN(x)) answer += x;
	}
	return parseInt(answer);
}

not using parseInt()

function solution(str) {
	let answer = 0;
	for (let x of str) {
		if (!isNaN(x)) answer = answer * 10 + +x;
	}
	return answer;
}