I read an article that we don't need to use var keyword anymore but I ran into a problem in my code where I could not use my variable inside an if block because I had declared it using let.
How could I solve this problem if we don't need to use var?
let elementWidth = el.getBoundingClientRect().width
let windowWidth = window.width // 400 px
if (windowWidth > elementWidth) {
elementWidth += 200
}
console.log(elementWidth) // 400 px