let arrays = [ [ ' ', ' ', ' ' ], [ ' ', ' ', ' ' ], [ ' ', ' ', ' ' ] ]
console.log(arrays);
for(i = 0; i < arrays.length; i++){
arrays[i][(arrays.length - 1) - i] = '-'
}
console.log(arrays); //[ [ ' ', ' ', '-' ], [ ' ', '-', ' ' ], [ '-', ' ', ' ' ] ]
This is the desired outcome.
The following code produces a different result.
let input = 6;
const diameter = input; //6
const centralValue = Math.ceil(diameter / 2); //3
const reverseArray = (array) => {return array.slice(0).reverse();} //reverses the array
// const makeUpperLeftArrays = function(centralValue){
//}
let createEmptyArray = (number) => {return new Array(number).fill(' ')} //creates an empty array
let emptyArray = createEmptyArray(centralValue);
let addEmptyArrays = function(array){
let addedEmptyArrays = [];
for(i = 1; i <= centralValue; i++){
addedEmptyArrays.push(array)
}
return addedEmptyArrays;
}
let addedEmptyArrays = addEmptyArrays(emptyArray);
let arrays = addedEmptyArrays
//[ [ ' ', ' ', ' ' ], [ ' ', ' ', ' ' ], [ ' ', ' ', ' ' ] ]
console.log(arrays);
for(i = 0; i < arrays.length; i++){
arrays[i][(arrays.length - 1) - i] = '-'
}
console.log(arrays);
I am in need of assistance...
I have attempted debugging, removing it from the function, changing the name, but to no avail.