Skip to content

Instantly share code, notes, and snippets.

View martin-mok's full-sized avatar

Martin martin-mok

  • /dev/null
View GitHub Profile
@martin-mok
martin-mok / CaesarsCipher.md
Last active July 5, 2023 16:56
freecodecamp: Caesars Cipher

Description

One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount. A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on. Write a function which takes a ROT13 encoded string as input and returns a decoded string. All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.

Tests

@martin-mok
martin-mok / RomanNumeralConverter.md
Last active May 19, 2023 20:31
freecodecamp: Roman Numeral Converter

Description

Convert the given number into a roman numeral. All roman numerals answers should be provided in upper-case.

Tests

@martin-mok
martin-mok / PalindromeChecker.md
Last active July 29, 2023 17:04
freecodecamp: Palindrome Checker

Description

Return true if the given string is a palindrome. Otherwise, return false. A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing. Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes. We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others. We'll also pass strings with special symbols, such as "2A3*3a2", "2A3 3a2", and "2_A3*3#A2".

Tests

@martin-mok
martin-mok / initializePerson.md
Last active January 13, 2020 20:16
freecodecamp: Make a Person javascript object initialization

Description

Fill in the object constructor with the following methods below:
getFirstName()
getLastName()
getFullName()
setFirstName(first)
setLastName(last)
@martin-mok
martin-mok / ArgumentsOptional.md
Created January 13, 2020 19:16
freecodecamp: Arguments Optional

Description

Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum. For example, addTogether(2, 3) should return 5, and addTogether(2) should return a function. Calling this returned function with a single argument will then return the sum: var sumTwoAnd = addTogether(2); sumTwoAnd(3) returns 5. If either argument isn't a valid number, return undefined.
@martin-mok
martin-mok / flatten.md
Last active January 13, 2020 00:20
freecodecamp: Steamroller flatten array
@martin-mok
martin-mok / LCM.md
Last active January 12, 2020 22:15
freecodecamp: Smallest Common Multiple

Description

Find the smallest common multiple of the provided parameters that can be evenly divided by both, as well as by all sequential numbers in the range between these parameters. The range will be an array of two numbers that will not necessarily be in numerical order. For example, if given 1 and 3, find the smallest common multiple of both 1 and 3 that is also evenly divisible by all numbers between 1 and 3. The answer here would be 6.

Tests

@martin-mok
martin-mok / sumOddFibs.md
Created January 12, 2020 00:12
freecodecamp: Sum All Odd Fibonacci Numbers

Description

Given a positive integer num, return the sum of all odd Fibonacci numbers that are less than or equal to num. The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8. For example, sumFibs(10) should return 10 because all odd Fibonacci numbers less than or equal to 10 are 1, 1, 3, and 5.

Tests

@martin-mok
martin-mok / convertHTML.md
Last active January 11, 2020 23:34
freecodecamp: Convert HTML Entities

Description

Convert the characters &, <, >, " (double quote), and ' (apostrophe), in a string to their corresponding HTML entities.

Tests

tests:
@martin-mok
martin-mok / js-encode-decode.md
Created January 11, 2020 23:08 — forked from yidas/js-encode-decode.md
JavaScript HTML Entities Encode & Decode