How to add sound at the event?

Sawing little game, I need to trigger a certain sound when you call a method of an object, how can I do that???
const view = {
 displayMessage(msg) {
 var messageArea = document.getElementById('messageArea');
 messageArea.innerHTML = msg;
},
 displayMiss(idOfElement) {
 var cell = document.getElementById(idOfElement);
 cell.setAttribute('class', 'miss');
},
 displayHit(idOfElement) {
 var cell = document.getElementById(idOfElement);
 cell.setAttribute('class', 'hit');
},
}

When you call the method view.displayHit("); the image appears and needs to play sound, how can I implement this?
Thanks in advance!!!
March 23rd 20 at 19:32
1 answer
March 23rd 20 at 19:34
Solution
for example to put on the page hidden audio

https://codepen.io/anon/pen/jojdxp?editors=1010
Super! I think that's it! - mallor commented on March 23rd 20 at 19:37

Find more questions by tags JavaScript