Skip to content

Commit

Permalink
Add a print statment that confirms deep copy of array occurred.
Browse files Browse the repository at this point in the history
  • Loading branch information
atom-box committed Oct 26, 2021
1 parent da07064 commit d09bb9a
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions accentInventer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ ww.test1 = "Go tell it on the mountain, over the water and through the sea.";
** Accepts an array
** Returns an object; keys are the original array vals, values are randomly chosen elements from the original array
*/
let invent = function(arr1) {
let altVowelScheme = function(arr1) {
// make 2 destroyable copies of the passed-in array
let arr2 = arr1.map( (item)=> {return item} ),
arr3 = arr1.map( (item)=> {return item} );

//####
//####
//####
arr2.push('z');
arr3.push('y');
console.log("length of array 1 is " + arr1.length);
console.log("length of array 2 is " + arr2.length);
console.log("length of array 3 is " + arr3.length);
return;

//////
//////
//////
let translator = {},
randomGrabPosition = 0,
originalItem = null;
Expand All @@ -26,10 +38,17 @@ let invent = function(arr1) {
originalItem = arr3.shift();
translator[originalItem] = arr2.splice(randomGrabPosition, 1)[0];
}
return translator;
// refactor to make an array-show function that can show any of the three arrays
const getter = (function(whichArray){
// todo For now,hardcode in a single array, ignore the parameter passed
return function(){return arr2};
})()

return getter;
}


let a = invent(['a', 'e', 'i', 'o', 'u']);
console.log(a);
let a = altVowelScheme(['a', 'e', 'i', 'o', 'u']);
// console.log(a());
// console.log("type of a is " + typeof a);

0 comments on commit d09bb9a

Please sign in to comment.