2

I have this code

if (found === true && premium === 'active' || premium === 'trialing') {
  var free = false
} else {
  var free = true
}

The express server works fine on both localhost and remotely on Heroku, I tried deploying this app to firebase hosting, one the error that prevented me to deploy is

75:17 error 'free' is already defined no-redeclare

I am not sure how to fix that, my goal is simply to pass free variable with a response like so

response.render('master.html', { links, profile, free })
1
  • have you tried putting var free before the if, and inside (if and else) just the assignation without var keyword? Commented Jun 4, 2020 at 4:21

2 Answers 2

1

You can declare this way and remove the else condition

let free = true;
if (found === true && premium === 'active' || premium === 'trialing') {
   free = false 
}
Sign up to request clarification or add additional context in comments.

Comments

1

https://eslint.org/docs/rules/no-redeclare

var free = true;
if (found === true && premium === 'active' || premium === 'trialing') {
  free = false
}

1 Comment

Thanks! the idea is there but I believe to either use global let or set variable like free = true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.