Skip to content

Instantly share code, notes, and snippets.

View CarlinCanales's full-sized avatar

Carlin Canales CarlinCanales

View GitHub Profile

Keybase proof

I hereby claim:

  • I am carlincanales on github.
  • I am carlincanales (https://keybase.io/carlincanales) on keybase.
  • I have a public key ASDO8icpU8y-aN7-C1n4P_p1wCvVVeceedvAhBt8vKyxygo

To claim this, I am signing this object:

@CarlinCanales
CarlinCanales / addAndSort.js
Created September 15, 2021 14:44
Add and sort
/*
Your previous Plain Text content is preserved below:
Given two arrays:
Array 1 - A distinct set of ice cream flavors
Array 2 - A set of ice cream flavors (may contain duplicates)
Please write a function that returns the values of Array 2 sorted by the order of Array 1.
@CarlinCanales
CarlinCanales / distinctPairs.js
Created September 15, 2021 14:43
Find distinct pairs that equal given number
function stockPairs(stocksProfit, target) {
// Write your code here
const pairs = [];
stocksProfit.forEach((profit1, idx1) => {
stocksProfit.forEach((profit2, idx2) => {
if (idx1 === idx2) return;
@CarlinCanales
CarlinCanales / SassMeister-input.scss
Last active September 8, 2016 21:17
My personal (simple) grid system based on Flexbox
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$gutter: 30px;
$columns: 12;
$max-width: 1000px;
* {
@CarlinCanales
CarlinCanales / getPropertyPathInObject.js
Created May 20, 2014 20:12
This function will take any object/json and a property/key you want to search for. It will return the path as a string. I just created this code and will continue to update it. If you find any bugs please let me know. Right now it will return the last instance of the value you pass it. I am working on returning an array of all the paths. The las…
function getPath(object, value) {
var pathToUse = "",
path = [],
level = 0;
function traverse(o, prop) {
@CarlinCanales
CarlinCanales / palindrome.js
Created October 4, 2013 15:00
Another challenge from another developer. This will verify if the string passed is a palindrome. Check out http://en.wikipedia.org/wiki/Palindrome for more details on what a palindrome is. The best test for this is Demetri Martin's Palindrome poem (which is one of the console.logs). It will strip all non-word characters, numbers and underscores …
function isPalindrome(str){
var iteration, i = 0;
// if str is only one character long, no matter the character, return false
if(str.length < 2) return false;
// set all characters to lowercase and strip any invalid characters
str = str.toLowerCase().replace(/[\W\d_]/g, "");
@CarlinCanales
CarlinCanales / aardvark.js
Last active December 24, 2015 16:19
This is a little challenge another developer hit me with. It will return the first letter after the first set of repeated letters in a string. For example, in aardvark it will return the 'r' after 'aa'. It will also return the letter in the correct case.
function aardvark(str){
var len = str.length, tempStr, iteration;
// if str is 2 characters or less return null right away
if(len < 3) return null;
// temporarily convert str to all lowercase to properly compare each character
tempStr = str.toLowerCase();