Understanding the basics of the scopes in Javascript. Solving the confusing part. Scopes in Javascript are very simple to understand yet when we execute the code they become the main culprit because sometimes we expect a different result and get a different output. And while debugging we keep scratching our…