Project Falcon
Welcome to JavaScript (JS)! The programming language that is native to the browser environment. This is an important language to learn because no matter what Back End language is in a project, JS is going to be essential. There are some conventions that should be followed when writing JS. The first of which is naming conventions. JS uses a camel case convention. So words are broken up by using capital letters. For example:
function myFunction() { // do something } const thisIsAVariable = true;
It is possible to name things in JS with any naming conventions, but camel case is widely used.
The next topic is comments. There is a widely accepted belief that all code should be commented. While this is true, the idea behind it may be a bit abstracted. Comments should only remain in code when absolutely necessary. Removing comments should be a part of refactoring code. Comments should be able to be removed and replaced by better naming conventions in the process.
// this function should replace dashes with spaces const placeholder = (str) => { return str.split('-').join(' '); };
While this is a useful function with a useful comment, it could be replaced with proper naming.
const replaceDashesWithSpaces = (str) => { return str.split('-').join(' '); };
Even though this may seem like a small change, it is a huge upgrade in code quality. It's important to use comments when they improve readability of the code, but they should be avoided when possible. A good example of when to use comments comes from a library called Lodash. They can describe what a complex function is going to do instead of having developers search around
NaNInfinityundefinednullObject.keys()Object.values()Object.entries()+-*/%+ but with stringstypeof=%%||??break, return, continueswitchfunction fuckOff() { // get about fucking off }
const iAmVariable = () => { // do stuff };
FizzBuzz without tests