DEV Community

Discussion on: The JavaScript Array Map() Method

Collapse
 
lmuzquiz profile image
lmuzquiz • Edited
const array = [2, 5, 9];
let squares = [];

for (let i = 0; i < array.length; i++) {
    squares.push(array[i] * array[i]));
}

console.log(squares); // [4, 25, 81]
console.log(array); // [2, 5, 9]

On this code block you say that it: " ...finds the square of each element in the array..."

It would be more accurate to say that the relevant part of the code calculates (as opposed to finding) the square root of each element in the array.

Of course by the find, i think you meant "calculate" but then again, why not use the word calculate instead?