X not defined error, even though it is?

I believe that the notorious global scope issue is at play here, but, more importantly, const means constant, so if you declare something const, you should not attempt to assign it.