Skip to content

Instantly share code, notes, and snippets.

View github524's full-sized avatar

Jason github524

View GitHub Profile
@github524
github524 / Codecademy_lodash.js
Created July 10, 2021 11:48
Codecademy Project - Lodash. write JavaScript code to deliver similar functionality as found in Lodash
// to use Lodash include in the head :
script src='https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js'
Make sure that you load lodash before the file that uses i
// Object containing the studied methods:
// clamp, inRange, words, pad, has, invert, findKey, drop, dropWhile and chunk.
const _ = {
/*
@github524
github524 / Codecademy_Mysterious_Organism.js
Last active July 10, 2021 11:50
Context: You’re part of a research team that has found a new mysterious organism at the bottom of the ocean near hydrothermal vents. Your team names the organism, Pila aequor (P. aequor), and finds that it is only comprised of 15 DNA bases. The small DNA samples and frequency at which it mutates due to the hydrothermal vents make P. aequor an in…
// Returns a random DNA base
const returnRandBase = () => {
const dnaBases = ['A', 'T', 'C', 'G']
return dnaBases[Math.floor(Math.random() * 4)]
}
// Returns a random single stand of DNA containing 15 bases
const mockUpStrand = () => {
const newStrand = []
for (let i = 0; i < 15; i++) {
@github524
github524 / CreditCardChecker.js
Created July 8, 2021 13:18
Codecademy Project: The Luhn algorithm is a series of mathematical calculations used to validate certain identification numbers, e.g. credit card numbers. The calculations in the Luhn algorithm can be broken down as the following steps: Starting from the farthest digit to the right, AKA the check digit, iterate to the left. As you iterate to the…
// All valid credit card numbers
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9];
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6];
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5];
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6];
// All invalid credit card numbers
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5];
const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3];