๐
Subtract Numbers
Subtract Numbers์
๋ฌธ ๊ธฐ์ด ๋ฌธ๋ฒ +5pts
Problem
Write a function that takes two numbers and returns their difference.
Examples
Input:
subtract(10, 4)Output:
6Input:
subtract(3, 8)Output:
-5Explanation
์ด ๋ฌธ์ ๋ **๋บ์ ์ฐ์ฐ์(-)**๋ฅผ ์ฌ์ฉํ์ฌ ๋ ์์ ์ฐจ์ด๋ฅผ ๊ณ์ฐํ๋ ๊ธฐ๋ณธ์ ์ธ ํจ์๋ฅผ ์์ฑํฉ๋๋ค. **๋บ์ ์ฐ์ฐ์ (-)** JavaScript์์ `-`๋ ๋ ์ซ์์ ์ฐจ์ด๋ฅผ ๊ณ์ฐํฉ๋๋ค. ์ฒซ ๋ฒ์งธ ์ซ์์์ ๋ ๋ฒ์งธ ์ซ์๋ฅผ ๋บ๋๋ค. **๋งค๊ฐ๋ณ์ ์์์ ์ค์์ฑ** ๋บ์ ์ ๋ง์ ๊ณผ ๋ฌ๋ฆฌ ๊ตํ๋ฒ์น์ด ์ฑ๋ฆฝํ์ง ์์ต๋๋ค: - subtract(10, 4) = 10 - 4 = 6 - subtract(4, 10) = 4 - 10 = -6 **์์ ๊ฒฐ๊ณผ** ์์ ์์์ ํฐ ์๋ฅผ ๋นผ๋ฉด ์์๊ฐ ๋ฉ๋๋ค: - subtract(3, 8) = 3 - 8 ...
View detailed explanation โKey Concepts
๋บ์
์ฐ์ฐ์ (-) ํจ์ ๋งค๊ฐ๋ณ์ ์์ ์์ ๊ฒฐ๊ณผ return ๋ฌธ
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.