Code Component not working when running in Pavlovia

You did it right, this is the error I mentioned earlier when I said that sound.Sound doesn’t really work in a code component in JavaScript. See here: Type Error: Cannot read property '_psychoJS' of undefined

Sound objects really need to be created in the builder, and while you can start or stop them or change their order in a code component, it is sadly not possible to create a new one from a code component.