Skip to content
Advertisement

Playing soundfile when hovering over specific object

Can anyone understand what I’m doing wrong? This code returns the error that “songs is not a function”.

JavaScript
JavaScript

Regards, Shape of Mustard

Advertisement

Answer

The problem was how you access to your object

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

Object properties must be accessed in the following ways songs.song1, or songs['song1'], the latter is useful in cases where the first character of the property is a number in that case you can’t do songs.1song, so you will have to do it as songs['1song'] – it is also useful when the property name you want to fetch is a variable.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement