Skip to content

Instantly share code, notes, and snippets.

View harrisonmalone's full-sized avatar

Harrison Malone harrisonmalone

View GitHub Profile
class Dog
attr_accessor :location
def initialize(name, age)
@name = name
@age = age
@location = location
@distance = 0
@walks = 0
@walk_data = []
end
5 <= 6
# for the less than or more than and equals to symbol remember that the order is always how it's actually read
# the less than and more than come first and then the equals to comes second in the way you say it
require 'date'
def days_since_born(year, month, day)
date = Date.new(year, month, day)
p date
today = Date.today
p today
result = (today - date).to_i
sentence = "I have been alive for #{result} days"
return sentence

Thomas Q2

we just need to go through the test with him and ensure that in future he puts down some kind of answer to get at least a few marks per question

perhaps we should have suggested this to everyone before the test started say something like

if you put down any answer to questions you're unsure of more likely than not you'll pick up a few marks

i don't know why he'd even think to put () as a representation of an empty string

items = [{ customer: "John", item: "Soup", cost: 8.50}, {customer: "Sarah", item: "Pasta", cost: 12}, {customer: "John", item: "Coke", cost: 2.50}]
puts "whats your name?"
customer = gets.chomp
filter = items.select do |item|
item[:customer] == customer
end
cost = filter.map do |item|
item[:cost]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
body {
margin: 0;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
@media only screen and (min-width: 200px) {
a {
require 'pry'
def is_string_in_array?(array, string)
array.each do |word|
if word == string
return true
end
end
return false
end
require 'pry'
def balanced_num(number)
# my arrays
number_array = number.to_s.chars.map(&:to_i)
lower_array = []
higher_array = []
# get the index positions that i need
if number_array.length.odd?
middle_number = number_array.length / 2
def divisible_by_five(num)
num % 5 == 0
end
p divisible_by_five(4)
def divisible_by_five_multiple(array_of_numbers)
divisible_by_five_array = []
not_divisible_by_five_array = []