This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Given a string containing a sentence (such as "Linode is really cool"), reverse each word in place, and then return the result. | |
function reverseWordsInPlace(sentence) { | |
let words = sentence.split(" "); | |
let reversedWords = []; | |
for (let i = 0; i < words.length; i++) { | |
let word = words[i].split(""); | |
var reversedWord = []; | |
for (let k = word.length - 1; k > -1; k--) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
function sortAverages(averages) { | |
var sorted = []; | |
for (var account in averages) { | |
sorted.push([account, averages[account]]); | |
} | |
sorted.sort(function(a, b) { | |
return a[1] - b[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We'll be using [Storedom](https://github.com/turingschool-examples/storedom) for the following challenges. | |
Write ActiveRecord query statements for the following problems. You're welcome to change the schema to fit your needs. Create a gist to store your solutions. We'll pop them into Slack first thing Tuesday morning. | |
## Required | |
* Find all the items that have the word "elegant" in it. | |
1. Item.where("name like ?", "%Incredible%") | |
* Add three orders to a user. | |
2. Order.create(user_id: user.id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_by(attribute, criteria) | |
return if entries.nil? | |
entries.select { |entry| entry.send(attribute.to_sym) == criteria.downcase.capitalize } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choose_attribute(attribute, criteria) | |
case | |
when attribute == "date" | |
find_by_date(criteria) | |
when attribute == "first_name" | |
find_by_first_name(criteria) | |
when attribute == "last_name" | |
find_by_last_name(criteria) | |
when attribute == "registration_date" | |
find_by_registration_date(criteria) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BoggleBoard | |
attr_accessor :board | |
def initialize(board) | |
@board = board | |
end | |
def create_word(board, *coords) | |
coords.map { |coord| board[coord.first][coord.last]}.join("") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'pry' | |
# Object Oriented Blackjack game | |
# 1) Abstraction | |
# 2) Encapsulation | |
class Card |