๐ŸŒˆ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค:Javascript] ๋ง์…ˆ์‹ ์ถœ๋ ฅํ•˜๊ธฐ

Eun_zii 2024. 4. 15. 16:50

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค Lv.0

- ๋ง์…ˆ์‹ ์ถœ๋ ฅํ•˜๊ธฐ

 

๐Ÿ’š ๋ฌธ์ œ์„ค๋ช…

 

๐Ÿ’š ์ œํ•œ์กฐ๊ฑด

  • 1 ≤ a, b ≤ 100

๐Ÿ’š ํ’€์ด

const readline = require('readline');
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let input = [];

rl.on('line', function (line) {
    input = line.split(' ');
}).on('close', function () {
    const a = Number(input[0]) 
    const b = Number(input[1])
    console.log(`${a} + ${b} = ${a+b}`);
});

 

โœ… 

a ์™€ b๋ฅผ ๊ฐ ๊ฐ ๋ณ€์ˆ˜์— ํ• ๋‹นํ•ด๋‘๊ณ  ๋ฐฑํ‹ฑ( ` ` ) ๊ณผ ${ } ๋ฅผ ์ด์šฉํ•ด ํ‘œํ˜„์‹ ์‚ฝ์ž…์„ ์‚ฌ์šฉํ•˜์˜€๋‹ค.

๐Ÿ’ก ${ } ์‚ฌ์ด์— ๋ณ€์ˆ˜๋‚˜ ์—ฐ์‚ฐ ๋“ฑ์„ ์‚ฝ์ž…ํ•  ์ˆ˜ ์žˆ๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ์ž…๋ ฅ๊ฐ’์ด 4 ์™€ 5์ผ๋•Œ, 4 + 5 = 9 ๋กœ ์ถœ๋ ฅํ• ์ˆ˜ ์žˆ๋‹ค.

728x90