Beat Mix - getNeighborPads clarity

Hey all - I’m having trouble understanding what exactly the Bonus portion of the Beat Mix project (Project 2) is asking. See below from the project:

As a bonus, you can choose to implement a function in script.js to play multiple synthesizer tones at once by writing:

  • a function called getNeighborPads that accepts an x, y, and a size parameter. In the application, these values refer to the synth grid: x and y zero-indexed from the bottom left of the grid, and size is a number representing the number of rows/columns in the square. getNeighborPads should return an array of neighbors, each in the form [xValue, yValue] . Neighbors are the squares immediately to the left, right, above, and below a grid position.

I’m having trouble deciphering what they are describing and why they are describing it. Do these pads only execute if a square block of the pads (whether “sized” 1x1, 2x2, 3x3) are triggered? So lost. Help!


Hi pkehr09 -

Sure you already moved on by now but for anyone that is coming after us. I had the same trouble, my impression when looking at the test details (I used console.log(x, y, size) in my code to display the tests that are being ran) is that size is the number of rows/columns in use, so in the case of Beat Mix it is 5. The x, y coordinates (being the horizontal and vertical position in the grid) can not be equal to or larger than this maximum (5) otherwise it is out of range of the array grid. So x and y can not be smaller than 0 (start positions of the array) and can not be equal or larger than size. This holds true for the selected key and its neighboring keys. So anything smaller than 0 and larger than 4 should be removed as it is outside of the array grid positions.

Thank you for your reply! I’ve grown just a smidge in my understanding of javascript as a whole - so I will certainly go back to the beatMaker project with this new info. Thanks again for the help!