Skip to content

Instantly share code, notes, and snippets.

View jsmayo's full-sized avatar
👨‍💻

Jesse jsmayo

👨‍💻
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<meta charset="utf-8">
<title>Card Demo</title>
<style id="jsbin-css">
my-card {
display: block;
@jsmayo
jsmayo / superKeyword.js
Last active March 18, 2018 22:46
superKeyword created by jsmayo - https://repl.it/@jsmayo/superKeyword
// 1 - Create a class for for a Vehicle. Each vehicle should have a make, model and year property.
// 2 - Add an instance method called start which returns the string "VROOM!"
// 3 - Add an instance method called toString which returns the string "The make, model, and year are" concatenated with the make, model and year property
/* Examples
var vehicle = new Vehicle("Tractor", "John Deere", 1999)
vehicle.toString() // 'The make, model, and year are Tractor John Deere 1999'
*/
@jsmayo
jsmayo / staticMethods.js
Created March 18, 2018 14:12
staticMethods.js created by jsmayo - https://repl.it/@jsmayo/staticMethodsjs
count = 0;
class Person {
constructor(firstName, lastName, favoriteColor, favoriteNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.favoriteColor = favoriteColor;
this.favoriteNumber = favoriteNumber;
}
/*
Write a function called arrayFrom which converts an array-like-object into an array.
Examples:
var divs = document.getElementsByTagName('divs');
divs.reduce // undefined
var converted = arrayFrom(divs);
converted.reduce // function(){}....
*/
@jsmayo
jsmayo / closureExercise.js
Last active February 24, 2018 08:50
Closure Exercise created by jsmayo - https://repl.it/@jsmayo/Closure-Exercise
/*
Write a function called specialMultiply which accepts two parameters. If the function is passed both parameters, it should return the product of the two. If the function is only passed one parameter - it should return a function which can later be passed another parameter to return the product. You will have to use closure and arguments to solve this.
Examples:
specialMultiply(3,4); // 12
specialMultiply(3)(4); // 12
specialMultiply(3); // function(){}....
*/
@jsmayo
jsmayo / Some and Every Exercise.js
Created February 21, 2018 21:57
Some and Every Exercise created by jsmayo - https://repl.it/@jsmayo/Some-and-Every-Exercise
/*
Write a function called hasOddNumber which accepts an array and returns true if the array contains at least one odd number, otherwise it returns false.
Examples:
hasOddNumber([1,2,2,2,2,2,4]) // true
hasOddNumber([2,2,2,2,2,4]) // false
*/
function hasOddNumber(arr){
return arr.some(function(val) {
/*
Write a function called doubleValues which accepts an array and returns a new array with all the values in the array passed to the function doubled
Examples:
doubleValues([1,2,3]) // [2,4,6]
doubleValues([1,-2,-3]) // [2,-4,-6]
*/
function doubleValues(arr){
return arr.map(function(val, i, arr) {
@jsmayo
jsmayo / forEach Exercise.js
Created February 20, 2018 07:54
forEach Exercise created by jsmayo - https://repl.it/@jsmayo/forEach-Exercise
/*
Write a function called doubleValues which accepts an array and returns a new array with all the values in the array passed to the function doubled
Examples:
doubleValues([1,2,3]) // [2,4,6]
doubleValues([5,1,2,3,10]) // [10,2,4,6,20]
*/
function doubleValues(arr){
const newArr = [];
@jsmayo
jsmayo / forEach Exercise.js
Created February 19, 2018 07:31
forEach Exercise created by jsmayo - https://repl.it/@jsmayo/forEach-Exercise
/*
Write a function called doubleValues which accepts an array and returns a new array with all the values in the array passed to the function doubled
Examples:
doubleValues([1,2,3]) // [2,4,6]
doubleValues([5,1,2,3,10]) // [10,2,4,6,20]
*/
function doubleValues(arr){
const newArr = [];
@jsmayo
jsmayo / index.html
Created February 18, 2018 10:25
Jasmine Intro
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine.css">
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/jasmine-html.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.6.2/boot.js"></script>