λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°

ν”„μ—” 곡뢀/🫧 μ•Œκ³ λ¦¬μ¦˜ 곡뢀

[μ•Œκ³ λ¦¬μ¦˜ || ν”„λ‘œκ·Έλž˜λ¨ΈμŠ€] μ΅œλŒ“κ°’κ³Ό μ΅œμ†Ÿκ°’

728x90
λ°˜μ‘ν˜•
SMALL

split 으둜 λ‚˜λˆˆ λ’€, Number 둜 ν˜•λ³€ν™˜ν•΄μ„œ μ΅œλŒ€κ°’, μ΅œμ†Œκ°’μ„ κ΅¬ν–ˆλŠ”λ°, 

function solution(s) {
    const numArr = s.split(" ").map(Number)
    const max = Math.max(...numArr);
    const min = Math.min(...numArr);
    return `${min} ${max}`
}

 

μ•„λ‹ˆ 이게 뭐람

Math.min, Math.max λŠ” string 을 λ„£μœΌλ©΄ μ•Œμ•„μ„œ 숫자둜 λ³€ν™˜μ‹œν‚¨λ‹€.

function solution(s) {
    const arr = s.split(' ');

    return Math.min(...arr)+' '+Math.max(...arr);
}
const solution = s => Math.min(...s.split(" "))+ " "+ Math.max(...s.split(" "));

☝️ μ–˜μ²˜λŸΌ μ•„μ£Ό κ°„λ‹¨ν•˜κ²Œ λ‚˜νƒ€λ‚Ό 수 μžˆλ‹€.

 

 

728x90
λ°˜μ‘ν˜•
LIST