www.w3resource.com/javascript-exercises/javascript-basic-exercise-2.php
A Pen by Casey Burnett on CodePen.
var car = "Honda Civic"; | |
showCar(); | |
var showCar = function(){ | |
console.log(car); | |
}; | |
// Because of hoisting the function expression is hoisted prior to the assignment of the function expression. Thus the call of the showCar(); breaks . |
favouriteColor = "green"; | |
function showColor() { | |
var secondFavouriteColor = "red"; | |
console.log(favouriteColor); | |
console.log(secondFavouriteColor); | |
} | |
showColor(); | |
console.log(favouriteColor); | |
// doesn't display as local scope | |
console.log(secondFavouriteColor); |
var favouriteColor = "green"; | |
function showColor() { | |
console.log(favouriteColor); | |
} | |
showColor(); |
function showName () { | |
console.log("Casey Burnett") | |
} | |
showName() |