I’m working on the Drum Machine project in React, but I’ve having problems passing the value from an object to the triggerSound function.
-I’ve created a const object allKeys right after the render(). In it the keys are src (a url) and desc (description).
-The buttons are declared inside the return statement, and they are accessing the allKeys.src correctly:
-The triggerSound function is able to read the src and play the correct audio:
But since the button doesn’t have the allKeys.desc, it can’t access those values with a document.getElementById. The object is a constant, so shouldn’t it be accessible within the function?