-3
const company = "Big Bucks co.";                  
let profit = 900;               
let financeManager = "Richard";

if (profit < 1000) {                  
      var richardFired = true;            
      var financeManager = "Fay";               
} 

console.log(company);             
console.log(financeManager);          
console.log(richardFired);

Hey, I'm practicing my code! I'm trying to figure out why I am getting
SyntaxError: Identifier 'financeManager' has already been declared
I want the console.log(financeManager); to log Fay, but it is logging Richard.

Thanks, in advance!

  • 2
    Well the error message is spot-on. You declare `let financeManager = "Richard";` and later you declare `var financeManager = "Fay"; ` ... – Idos Mar 29 '21 at 18:13

1 Answers1

1

remove var inside if, you're declaring it again

Renz Ivan
  • 59
  • 6
  • Thanks! I thought let financeManager = "Richard"; and financeManager = "Fay" were in two different scopes and so reassigning financeManager's value wouldn't log Fay outside of the block it is in? – Dario Charles Mar 29 '21 at 19:11
  • It would be on different scope if you declared ```let financeManager``` inside if block. Check this out: https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var – Renz Ivan Mar 30 '21 at 05:27