๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
์•Œ๊ณ ๋ฆฌ์ฆ˜

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 1๋‹จ๊ณ„ : ์ง์ˆ˜์™€ ํ™€์ˆ˜

by _ํ† ๋งคํ†  2022. 11. 2.
728x90

๐Ÿ–ฑ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค 1๋‹จ๊ณ„ : ์ง์ˆ˜์™€ ํ™€์ˆ˜ ๐Ÿ–ฑ


#1.์ •์ˆ˜ num์ด ์ง์ˆ˜์ผ ๊ฒฝ์šฐ "Even"์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ํ™€์ˆ˜์ธ ๊ฒฝ์šฐ "Odd"๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜, solution์„ ์™„์„ฑํ•ด์ฃผ์„ธ์š”.

์ œํ•œ ๋ฒ”์œ„ : num์€ int ๋ฒ”์œ„์˜ ์ •์ˆ˜์ž…๋‹ˆ๋‹ค. 0์€ ์ง์ˆ˜์ž…๋‹ˆ๋‹ค.

function solution(num) {
    var answer = '';
    if(num%2 == 0){
        answer = "Even";
    }else {
        answer = "Odd";
    }
    return answer;
}

์ง์ˆ˜๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด์„  2๋ฅผ ๋‚˜๋ˆ„์—ˆ์„ ๊ฒฝ์šฐ ๋‚˜๋จธ์ง€๊ฐ€ 0์ด ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. if๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ’์ด ๋‚˜์˜ค๋„๋ก ํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค.


728x90

๋Œ“๊ธ€


Lucky Charms Rainbow
js
html
css