Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
ryanckulp / ifElse.js
Created January 1, 2018 22:31
if/else example in JavaScript
var x = 4;
if (x == 4) {
console.log("Correct!");
} else {
console.log("Incorrect!");
}
@ryanckulp
ryanckulp / if_else_python.py
Created January 1, 2018 22:29
if/else example in Python
if x == 5:
print("Correct!")
else:
print("Incorrect!")
@ryanckulp
ryanckulp / parameterless_methods.rb
Last active January 1, 2018 22:04
useful methods without parameters, in Ruby
def date_night?
Date.today.wday == 5 # is today the weekday 5 out of 7?
end
def bitcoin_price
Bitcoin.get_current_price
end
@ryanckulp
ryanckulp / addition_method.rb
Created January 1, 2018 21:55
method with addition operation in Ruby
def addition_problem(user_answer, correct_answer)
if user_answer == correct_answer
alert "Correct!"
else
alert "Incorrect!"
end
end
# question 1, answer: 4
addition_problem(3, 4) # returns 'false'
@ryanckulp
ryanckulp / x_assignment_y_equals.rb
Created January 1, 2018 21:51
assignment and is-equal example in Ruby
x = 3
y = 3
x == y # => returns 'true'
x = 4
y = 5
x == y # => returns 'false'
@ryanckulp
ryanckulp / if_x_y.rb
Created January 1, 2018 21:47
if example with 2 variables in Ruby
if x == y
alert "Correct!"
else
alert "Incorrect!"
end
@ryanckulp
ryanckulp / if_if_if.rb
Created January 1, 2018 21:38
multiple if examples in Ruby
# question 1, answer: 4
if 2 + 2 == x
alert "Correct!"
else
alert "Incorrect!"
end
# question 2, answer: 11
if 4 + 7 == x
alert "Correct!"
@ryanckulp
ryanckulp / else.rb
Created January 1, 2018 21:25
else example in Ruby
if 2 + 2 == x
alert "Correct!"
else
alert "Incorrect!"
end
@ryanckulp
ryanckulp / algebra.rb
Created January 1, 2018 21:24
algebra and Ruby
2 + 2 == x
# what is x?
@ryanckulp
ryanckulp / if_x.rb
Created January 1, 2018 21:23
if X example in Ruby
if 2 + 2 == x
alert "Correct!"
end