Javascript Array Question 23

Introduction

Square the Values

Given an array, square each value in the array.

function sqr_values(arr) {
  //code here
  return arr;
}
sqr_values([2,3,4]);
function sqr_values(arr) {
  for (var i = 0; i < arr.length; i++) {
    arr[i] *= arr[i];//from ww  w  .j  ava  2 s.c  o  m
  }
  return arr;
}
sqr_values([2,3,4]);



PreviousNext

Related