Javascript does not have a built-in function to produce a beep sound directly. However, you can achieve a similar effect using the HTML5 Audio API to play a short audio file or use the 'navigator.vibrate()' API to vibrate the device if it supports it.
<!DOCTYPE html> <html> <head> <title>Beep Sound in JavaScript</title> </head> <body> <button onclick="playBeep()">Beep</button> <script> function playBeep() { // Create an audio element and set its source to an audio file const audioElement = new Audio('path/to/beep-sound.mp3'); // Play the audio audioElement.play(); } </script> </body> </html>
Note that you should replace '/path/to/beep-sound.mp3' with the actual path to your audio file.