jeudi 5 septembre 2019

how can i use variables in a if statement and out of it?

I const a variable in an if statement but I can't use the variable out of the statement

const a = 1

const b = 1

if (a == b ){
    const c = 1
    console.log(c)    
}
console.log(c)

fist it gives me c ( in the if statement) then it gives me an error(out of the if statement)

Aucun commentaire:

Enregistrer un commentaire