Using a variable assigned in let and const keywords with same name inside a function

Problems:
So, i tried to create a variable sentence using let keywords which has the same name with the one assigned using const keywords. I print that variable into the console in two way;

  1. The one inside the For loop; and
  2. The one outside the For loop
    When its printed, the value that returned inside the For loop are 5 as i expected. But when i print sentence variable outside the For loop, it returns 5 too instead of text with the parameter that is assigned in the first place. can anyone explain this to me why it happens?

Code


function printManyTimes(str) {
  "use strict";

  const sentence = str + " is cool!";
  
  for(let i = 0; i < str.length; i+=2) {
    let sentence = 5;
    //inside the For loop
    console.log(sentence);
  }
  //outside the For loop
  console.log(sentence);
}
printManyTimes("Hello World");

Test Code:
https://playcode.io/405085

First it’s print 5 times “5”, then it will execute

so it’s normal to have 5 times “5” then “Hello World is cool!”