Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Creating Unchanging Variables With const

Capitalize constants?

I kind of remember a rule of thumb that declared constants should be capitalized. Something like const PI = 3.1415926535 instead of const pi = 3.1415926535. Is this more of a style thing or is it best practice to capitalize or not capitalize constants?

1 Answer

Steven Parker
Steven Parker
231,007 Points

Declaring constants with uppercase is a common convention.

It is recommended by the Google JavaScript Style Guide and the w3schools Coding Conventions, but it's not a universal practice.

But being consistent with naming conventions is itself a "best practice".

John Bastian Bolhano
John Bastian Bolhano
4,800 Points

Do you use constants with uppercase?

Steven Parker
Steven Parker
231,007 Points

Personally? It depends on the intended audience of the code. But I do try to be consistent within a project about what naming convention I'm using.