📚

Square Array Values

Square Array Values
쉬움 배열 +10pts

Problem

Write a function that squares every number in an array.

Examples

Input: squareArray([1, 2, 3])
Output: [1, 4, 9]

Explanation

이 문제는 **map 메서드**로 배열의 각 요소를 제곱하는 방법을 학습합니다. **제곱 계산 방법** - `x * x`: 가장 직관적 - `x ** 2`: 거듭제곱 연산자 - `Math.pow(x, 2)`: Math 메서드 **[1, 2, 3] 제곱 과정** - 1 * 1 = 1 - 2 * 2 = 4 - 3 * 3 = 9 - 결과: [1, 4, 9] **음수의 제곱** 음수를 제곱하면 양수가 됩니다: - (-2) * (-2) = 4...

View detailed explanation →

Key Concepts

map 메서드 제곱 연산 배열 변환 거듭제곱
Time: O(n) Space: O(n)
solution.js
Ctrl + Enter
Run tests to see results here.