Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

square element in array

let arr = [1, 2, 3, 4, 5, 6, 7];
let square = (item) => item * item;

function arraySq(func, arr) {
    let newArr = [];
    arr.forEach((element) => {
        newArr.push(func(element));
    });
    return  newArr;
}

console.log(arraySq(square, arr));
Source by james.codegym.vn #
 
PREVIOUS NEXT
Tagged: #square #element #array
ADD COMMENT
Topic
Name
6+6 =