JavaScript Code

JavaScript const – Uncaught TypeError: Assignment to constant variable


Problem

const PI = 3.14159;
PI = 3.1415926; //Uncaught TypeError: Assignment to constant variable

Solution

constant variables cannot be reassigned. second statement in the above code must not be written in the same block-scope.

const PI = 3.14159;