Skip to content

Instantly share code, notes, and snippets.

@aspencer8111
aspencer8111 / loops.js
Last active September 5, 2017 13:35
JS Looping
// What will the JS below print to the screen?
var fruits = ['apples', 'pears', 'pinapple', 'grapes']
for(var i = 0; i < fruits.length; i++) {
console.log(fruits[i])
}
@aspencer8111
aspencer8111 / expression.js
Created September 5, 2017 13:31
Basic JS Expression Test
// What will this expression evaluate to?
3 > 3
@aspencer8111
aspencer8111 / heavy_ball.js
Created August 7, 2017 15:23
Heavy Ball JS Starter
function findBall(scale, ballCount) {
var heavySet = [];
for(var i = 0; i < ballCount; i++) {
heavySet.push(i);
}
while(heavySet.length > 1) {
var firstRight = Math.ceil(heavySet.length / 3);
var left = heavySet.slice(0, firstRight);
var right = heavySet.slice(firstRight, Math.ceil(heavySet.length / 3) * 2);
....
@aspencer8111
aspencer8111 / counterObj.js
Created July 26, 2017 15:44
Using a counter Obj
var arr = [1, 1, 3, 4, 6, 4, 5, 7, 89, 90, 0, 5, 32, 1, 1, 1]
var mostOccurances = function(arr){
var counterObj = {}
for(var i=0; i<arr.length; i++){
var num = arr[i]
if(counterObj[num] == undefined){
counterObj[num] = 1
} else {
@aspencer8111
aspencer8111 / plan.js
Created July 17, 2017 22:56
Solution to Plan your day kata
function dayPlan (hours, tasks, duration){
var minutesAvail = hours * 60
var totalWorkMin = tasks * duration
if(totalWorkMin > minutesAvail){
return "You're not sleeping tonight!"
} else {
var answer = []
var timeRemaining = minutesAvail - totalWorkMin
var chopped = timeRemaining / (tasks - 1)
@aspencer8111
aspencer8111 / jadenCase.js
Created June 28, 2017 20:15
jadenCase.js
String.prototype.toJadenCase = function () {
var words = this.split(' ');
var newSentanceArray = [];
for(var i=0; i<words.length; i++){
var word = words[i];
var capitalizedWord = word.charAt(0).toUpperCase() + word.slice(1);
newSentanceArray.push(capitalizedWord)
}
return newSentanceArray.join(' ');
resources :widgets
# Create
GET /widgets/new -> New action controller -> @widget = Widget.new -> view
POST /widgets -> Create action controller -> @widget.save(params) -> reidrect
# Read
GET /widgets -> Index action controller -> @widgets = Widget.all
GET /widgets/:id -> Show action controller -> @widget = Widget.find(params(:id))
@aspencer8111
aspencer8111 / template.md
Last active May 23, 2017 18:23
Suggested Curriculum Template V2

NOTE This template provides a structured and consistent way to create new checkpoints. Please do your very best to include/use each section of this template.

Overview and Purpose

In this checkpoint you _________________________.

Objectives (phrased in a Bloom-y way)

  • Create ________
  • Evaluate ________
@aspencer8111
aspencer8111 / Try-Real-Assignment.md
Created May 22, 2017 16:08
Git Real Assignment
  1. Create a feature branch off of the repository you created after the Try Git checkpoint.
  2. Call your feature branch 'favorite foods'
  3. Add a new file called 'favorite_foods.md'
  4. Commit the file to this new branch
  5. Push the new branch up to GitHub
  6. Send the a link to the repo to your mentor

On your computer, create a folder called lessons_learned. Inside the directory create a file called Readme.md. Use Create a new GitHub repository called Lessons Learned. Using Markdown, add a list of all the things you have learned so far at Bloc.

  1. Save the file
  2. Initialize a new git repo
  3. Commit the readme file
  4. Add Github as a remote git repository
  5. Push the commit (with the file in it) to your new Github repository
  6. Tweet or post on Facebook that you have just made your first git post (hint if you mention @bloc we may retweet you or reply back)