Skip to content

Instantly share code, notes, and snippets.

View jcates2685's full-sized avatar

Jon Cates jcates2685

View GitHub Profile
@jcates2685
jcates2685 / deep-comparison.markdown
Last active March 9, 2017 15:44
Deep Comparison
@jcates2685
jcates2685 / script.js
Created March 7, 2017 18:20
Sum of a Range
// Write a range function that takes two arguments, start and end, and returns an array containing all the numbers from start up to (and including) end.
// Next, write a sum function that takes an array of numbers and returns the sum of these numbers. Run the previous program and see whether it does indeed return 55.
// As a bonus assignment, modify your range function to take an optional third argument that indicates the “step” value used to build up the array. If no step is given, the array elements go up by increments of one, corresponding to the old behavior. The function call range(1, 10, 2) should return [1, 3, 5, 7, 9]. Make sure it also works with negative step values so that range(5, 2, -1) produces [5, 4, 3, 2].
function range(start, end, step){
var arr = [];
for(var i = start; step > 1 || step === undefined ? i <= end : i >= end; step ? i = i + step : i++){
arr.push(i);

Bean Counting

Counts the number of occurrences of a specified character in a string. This is an exercise in Eloquent JavaScript

A Pen by Jon on CodePen.

License.

@jcates2685
jcates2685 / iseven.markdown
Last active February 20, 2017 22:37
isEven

isEven

Recursive function to determine if a number is even. Another exercise from Eloquent JavaScript.

A Pen by Jon on CodePen.

License.

@jcates2685
jcates2685 / minimum.markdown
Last active February 20, 2017 22:37
Minimum

Minimum

Just a quick function for finding the minimum between two numbers without using the Math.min function. This is one of the exercises in Eloquent JavaScript

A Pen by Jon on CodePen.

License.

@jcates2685
jcates2685 / js-console-chess-board.markdown
Last active March 7, 2017 18:20
JS Console Chess Board