Adding Const defaultPlayerVars =

Inspired by that comment, here is a separate function that creates the player options:

    function createPlayerOptions(settings) {
        const defaultOptions = {
            height: 207,
            width: 277
        };
        const defaultPlayerVars = {
            autoplay: 0,
            controls: 1,
            disablekb: 1,
            enablejsapi: 1,
            fs: 0,
            iv_load_policy: 3,
            rel: 0
        };

        function paramInOptions(options, param) {
            if (settings[param] !== undefined) {
                options[param] = settings[param];
                delete settings[param];
            }
            return options;
        }

        const optionParams = ["width", "height", "videoid", "host"];
        const options = optionParams.reduce(paramInOptions, {});
        const playerOptions = Object.assign({}, defaultOptions, options);
        const playerVars = Object.assign({}, defaultPlayerVars, settings);

        playerOptions.playerVars = playerVars;
        return playerOptions;
    }

We can now use that createPlayerOptions function and remove the previously needed comments.

    function initPlayer(videoWrapper, settings = {}) {
        const video = videoWrapper.querySelector(".video");
        const playerOptions = createPlayerOptions(settings);
        const player = videoPlayer.addPlayer(video, playerOptions);
        videoWrapper.player = player;
    }

The updated code is found at https://jsfiddle.net/w90apn74/

1 Like