const fs = require('fs');
const path = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
const input = fs.readFileSync(path).toString().split('\n');
const firstRow = input[0].split(' ').map(Number);
const secondRow = input[1].split(' ').map(Number);
const N = firstRow[0];
const X = firstRow[1];
const array = secondRow;
function solve(N, X, array) {
console.log(...array.filter((number) => number < X));
}
solve(N, X, array);
๊ฐ์ธ์ ์ผ๋ก spread์ filter()๋ฅผ ์ฌ์ฉํด์ ํ์๋ค๋ ๊ฒ ๋ฟ๋ฏํ ๋ฌธ์ !
๋ฌธ์ ์์ ์๊ตฌํ๋ ๊ฒ์ ์๋ง N๊ฐ์ ํ์๋ก for๋ฌธ์ ๋๋ ค์ ์ฒ๋ฆฌํ๋ ๋ฐฉ๋ฒ์ผ ๊ฒ ๊ฐ์๋ฐ,
์์ ๊ฐ์ด ํ๋ฉด ํจ์ฌ ๊ฐ๋จํ๊ณ ๊น๋ํ๊ฒ ํ ์ ์๋ ๊ฒ ๊ฐ๋ค. :)
๋ฐฐ์ธ์๋ก ์๋ฐ์คํฌ๋ฆฝํธ ๋๋ฌด ์ฌ๋ฏธ์๋ค. :)
'๐ JavaScript > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JS] 1110 (0) | 2022.05.12 |
---|---|
[JS] 10951 (0) | 2022.05.12 |
[JS] 2438 (0) | 2022.05.11 |
[JS] 15552 (0) | 2022.05.09 |
[JS] 10950 (0) | 2022.05.08 |