Where should this piece of code be placed within the javascript?

After improving this code, where should it be placed?

    button.addEventListener("mousedown", function (evt) {
        if (evt.detail > 1) {
            evt.preventDefault();
        }
    }, false);

Towards the bottom
Which is where I originally had it placed, should I stick with this spot?

Above:
sent.addEventListener("click", function () {


or towards the top,

Above:
function playPauseIcon(play) {

Full Code:

(function iife() {
    "use strict";
    const player = document.getElementById("player");
    const button = document.getElementById("button");
    const value = document.getElementById("input");
    const sent = document.getElementById("sent");

    function playPauseIcon(play) {
        if (play) {
            button.classList.add("is-playing");
        } else {
            button.classList.remove("is-playing");
        }
    }
    button.addEventListener("click", function () {
        if (player.paused) {
            player.play();
            playPauseIcon(true);
        } else {
            player.pause();
            playPauseIcon(false);
        }
    });

    sent.addEventListener("click", function () {
        player.src = value.value;
        player.volume = 1.0;
        playPauseIcon(true);
    });
}());

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.