How does the fruit variable gets overwritten in the if block, but the color variable doesn't gets overwritten in the function block ?
var fruit = "apple";
if(fruit){
    var fruit = "mango";
    console.log(fruit); // mango
}
console.log(fruit); // mango
var color = "blue";
function displayColor(){
    var color = "red";
    console.log(color);
}
displayColor(); // red
console.log(color);  // blue
 
    