I have this error when I define a const variable in a code block:
Uncaught SyntaxError: Unexpected identifier
I have already checked if I missed a extra comma, colon, parenthesis, quote or bracket, but still I get the error after I replaced the comma into curly brackets.
It works when I remove the variables and replace the a in Math.pow in 10. So what is going wrong with the const variables?
const multipleCircles = [{
calc1: {
const a = 10;
area: Math.PI * Math.pow(a, 2);
},
calc2: {
const a = 100;
area: Math.PI * Math.pow(a, 2);
}
}];
console.log(multipleCircles);