Arrow Functions

This function creates a circle and adds it to the div contaianer. You can pick any color for it to be by passing it as the parameter. (Made from scratch).

Named Function

            function colorCircle(color) {
                const circ = document.createElement('div');
                circ.className = 'circ';
                circ.style.backgroundColor = color;
                document.querySelector('#container').appendChild(circ);
            }
            colorCircle('royalblue');
        

Function Expression

            const colorCircle = function(color) {
                const circ = document.createElement('div');
                circ.className = 'circ';
                circ.style.backgroundColor = color;
                document.querySelector('#container').appendChild(circ);
            }
            colorCircle('royalBlue');
        

Arrow Function

            const colorCircle = color => {
                const circ = document.createElement('div');
                circ.className = 'circ';
                circ.style.backgroundColor = color;
                document.querySelector('#container').appendChild(circ);
            }
            colorCircle('royalBlue');