# [Algorithm/JS] ๋ฐฑ์ค€ 10998๋ฒˆ AxB

๐Ÿ”— ๋ฌธ์ œ ๋ฐ”๋กœ๊ฐ€๊ธฐ (opens new window)

# Question

๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, AxB๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

# Input

์ฒซ์งธ ์ค„ A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค (0 < A, B < 10)

# Output

์ฒซ์งธ ์ค„์— AxB๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

# Example Input

3 4
1

# Example Output

12
1

# Solution 1

๋ฐฐ์—ด ๋ฉ”์†Œ๋“œ reduce ์‚ฌ์šฉ

const fs = require('fs');
const input = fs.readFileSync('/dev/stdin').toString().split('').map(Number);

let answer = input.reduce((a, b) => {
  return a * b;
});

console.log(answer);
1
2
3
4
5
6
7
8

# Solution 2

๊ตฌ์กฐ๋ถ„ํ•ด ํ• ๋‹น

const fs = require('fs');
const input = fs.readFileSync('dev/stdin').toString().split(' ').map(Number);
const [a, b] = input;
console.log(a * b);
1
2
3
4
Last Updated: 2022. 6. 5. ์˜คํ›„ 3:42:39