Tell us what’s happening:
Describe your issue in detail here.
My code won’t increment my multiplier variable and I’m having trouble visualizing it as I don’t have a debugger. Show me the issue please and also if there’s a resource to help me debug JavaScript visually, let me know!
**Your code so far**
function chunkArrayInGroups(arr, size) {
let blankArray = [];
let blankArray2 = [];
let multiplier = 1;
for (let i = 0; i < arr.length; i++) {
console.log(blankArray.push(arr[i]));
}
let slice1 = blankArray.slice(0,size); // always slices the correct first element
let slice2 = blankArray.slice(size, size + slice1.length); // always slices the correct 2nd element.
let slice3 = blankArray.slice( 2 * size, 2 * size + slice1.length); //always slice 3rd element.
let slice4 = blankArray.slice( 3 * size, 3 * size + slice1.length); //always slice 4th element. So on and so forth adding 1 to the multiplier.
//console.log(slice);
console.log(slice1);
console.log(slice2);
console.log(slice3);
console.log(slice4);
//blankArray.push(slice2); //adds to the back
//blankArray.unshift(slice2); //adds to the front
blankArray2.push(slice1);
let slice = blankArray.slice(multiplier * size, multiplier * size + slice1.length); // always slices the correct 2nd element and so on as multiplier increments.
for (let i = 0; i < arr.length; i++) {
if (slice !== []) {
blankArray2.push(slice);
multiplier++;
}
}
return blankArray2;
}
console.log(chunkArrayInGroups(["a", "b", "c", "d"], 2));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4));
console.log(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Chunky Monkey
Link to the challenge: