Don't forget let and const are already block scoped, so a simple alternative to your let block example is this:
letcatName='Oswald'letcatAge=2.5{letcatName='Luna',catAge=2console.log(`${catName} (${catAge} years old)`)// Luna (2 years old)}console.log(`${catName} (${catAge} years old)`)// Oswald (2.5 years old)
Don't forget
let
andconst
are already block scoped, so a simple alternative to yourlet
block example is this:You're right, thanks - I'll update the article now.