"var"_"let"_"const"

by upigilam

JavaScript

// what wrong with this code
var timesCalled = 0;
function countUp() {
   let thisCallNumber = timesCalled++;
   const greeting = `Called ${timesCalled} times`;
   if (timesCalled === '3') {
     greeting = "Woah woah slow down there...";
   }

   console.log(greeting);
}

countUp();
countUp();
countUp();
console.log(`The last call was #${thisCallNumber}`);