Skip to content

Instantly share code, notes, and snippets.

View FrozenIce0617's full-sized avatar
🏡
Working from home

SuccessTracker FrozenIce0617

🏡
Working from home
View GitHub Profile
@FrozenIce0617
FrozenIce0617 / ARC TEST - 1st
Last active August 28, 2020 18:31
Arc Short Quiz (React)
let React = require('react');
// TODO: Create the Notification Component
const map = {
success: 'success',
message: 'info',
caution: 'warning',
error: 'danger'
};
@jonkemp
jonkemp / do-not-use-switch.md
Last active April 10, 2024 14:44
'Don’t use switch' excerpted from 'Programming JavaScript Applications' by Eric Elliott, https://www.oreilly.com/library/view/programming-javascript-applications/9781491950289/

Don't Use switch

JavaScript has pretty normal control-flow statements that use blocks delineated by curly braces. There is an exception to this: the switch ... case statement. The strange thing about switch ... case is that you must include the keyword break at the end of each case to prevent control from falling through to the next case. Fall through is a trick that allows you to let more than one case be executed. Control will fall through automatically to the next case unless you explicitly tell it not to with break. However, like the optional semicolons and curly braces, it's possible to forget break when you really should have used it. When that happens, the bug is difficult to find because the code looks correct. For that reason, the break statement should never be left off of a case, even by design.

With that said, JavaScript has an elegant object-literal syntax and first-class functions, which makes it simple to create a keyed method lookup. The object you create for your method lookup is call

@parmentf
parmentf / GitCommitEmoji.md
Last active May 24, 2024 00:27
Git Commit message Emoji