Skip to content

Instantly share code, notes, and snippets.

@jgresalfi
jgresalfi / eyePalindrome.js
Created September 4, 2016 20:18
Palindromes and regexp...hooray!
function palindrome(str) {
// Good luck!
var re = /[\s\!\@\#\$\%\^\&\*\(\)\+\=\-/\\\\:\_]/g,
cleanStr,
revStr;
cleanStr = str.toLowerCase().replace(re, "");
revStr = cleanStr.split("").reverse().join("");
if (cleanStr === revStr) {
return true;
} else { console.log(cleanStr); }
@jgresalfi
jgresalfi / randNum_v2.js
Created September 4, 2016 20:17
Random number guessing game - refactor
"use strict";
var upper = 10000,
numToGuess = getRandomNumber(upper),
compGuess,
numOfGuesses = 0;
function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
}
@jgresalfi
jgresalfi / randNum.js
Last active September 4, 2016 20:16
Random number guessing game.
"use strict";
var upper = 10000,
numToGuess = getRandomNumber(upper),
compGuess = getRandomNumber(upper),
numOfGuesses = 0,
correctGuess = false;
function getRandomNumber(upper) {
return Math.floor( Math.random() * upper ) + 1;
/* If you have a sticky bar at the top of a webpage that's the same color as the page background, this will fade in a drop shadow below the bar to create a boundary on scroll */
// jQuery
$(document).ready(function(){
var a=$(".sticky-top-bar");
$(window).scroll(function(){
if($(document).scrollTop()>50){a.addClass("top-bar-shadow")
}else{a.removeClass("top-bar-shadow")}})});
@jgresalfi
jgresalfi / hs-boilerplate.css
Created May 3, 2016 14:34
Hubspot Boilerplate CSS
/* @import url('http://example.com/example_style.css'); */
/**
* CSS @imports must be at the top of the file.
* Add them above this section.
*/
/* ==========================================================================