SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Write a JavaScript program to create a new array taking
  2. the middle elements of the two arrays of integer and each length 3.*/
  3.  
  4. function createNewArray(array1, array2) {
  5.  
  6.   var middleElementArray1 = array1.slice(1, -1);
  7.   var middleElementArray2 = array2.slice(1, -1);
  8.  
  9.   var newArray = [middleElementArray1 , middleElementArray2];
  10.  
  11.   return newArray;
  12. }
  13.  
  14. console.log(createNewArray([4, 7, 10], [5, 22, 3]));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top