Skip to content

Instantly share code, notes, and snippets.

View Folasayo-Samuel's full-sized avatar
:octocat:
I may be slow to respond.

FOLASAYO SAMUEL OLAYEMI Folasayo-Samuel

:octocat:
I may be slow to respond.
View GitHub Profile
@Folasayo-Samuel
Folasayo-Samuel / Validate US Telephone Numbers
Created February 21, 2022 17:36 — forked from efarioli/Validate US Telephone Numbers
Return true if the passed string is a valid US phone number. The user may fill out the form field any way they choose as long as it is a valid US number. The following are examples of valid formats for US numbers (refer to the tests below for other variants): 555-555-5555 ||| (555)555-5555 ||| (555) 555-5555 ||| 555 555 5555 ||| 5555555555 ||| 1…
//javascript
function telephoneCheck(str) {
if (!balancedParens(str)){
return false;
}
//remove whitespace
var newStr = str.replace(/\s/g, '');
@Folasayo-Samuel
Folasayo-Samuel / CaesarsCipher.md
Created February 21, 2022 17:11 — forked from martin-mok/CaesarsCipher.md
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

@Folasayo-Samuel
Folasayo-Samuel / romanNumConverter.js
Created February 21, 2022 17:05 — forked from tianmingzuo/romanNumConverter.js
Roman Numeral Converter: Convert the given number into a roman numeral. All roman numerals answers should be provided in upper-case.
function convertToRoman(num) {
let roman = '';
let roman1 = '';
let roman10 = '';
let roman100 = '';
let roman1000 = '';
let numStr = '' + num;
if(num<10){
switch(numStr[0]){
case '1': roman1 = 'I'; break;
@Folasayo-Samuel
Folasayo-Samuel / composing-route-in-react-router-v6.md
Created January 24, 2022 08:43 — forked from mjackson/composing-route-in-react-router-v6.md
Notes on route composition in React Router v6, along with a suggested improvement you can make today to start upgrading

Composing <Route> in React Router v6

Composition of <Route> elements in React Router is changing in v6 from how it worked in v4/5 and in Reach Router. React Router v6 is the successor of both React Router v5 and Reach Router.

This document explains our rationale for making the change as well as a pattern you will want to avoid in v6 and a note on how you can start preparing your v5 app for v6 today.

Background

In React Router v5, we had an example of how you could create a element](https://github.com/remix-run/react-router/blob/320be7afe44249d5c025659bc00c3276a19f0af9/packages/react-router-dom/examples/Auth.js#L50-L52) to restrict access to certain routes on the page. This element was a simple [wrapper around an actual element that made a simple decision: is the user authenticated or not? If so, ren