Edit in JSFiddle

// Example 1 - Difference between 'function expressions' & 'function statements'
var speak = function() { 
    // we are invoking the functions before they are defined (function hoisting)
    sayYes(); 
    sayNo(); 
 
    function sayYes() { alert('Yes');};       //function statement  - will succeed
    
    var sayNo = function() { alert('No');};   //function expression - will fail
}();