Skip to content

Instantly share code, notes, and snippets.

View sevperez's full-sized avatar

Severin Perez sevperez

View GitHub Profile
arr = [“a”, “b”, “c”]
arr[1] # => “b”
arr[1] = “z”
arr[1] # => “z”
class Lion
attr_reader :name, :age, :weight, :height, :bravery
def initialize(name, age, weight, height, bravery)
@name = name
@age = age
@weight = weight
@height = height
@bravery = bravery
end
class Lion
include Comparable
attr_reader :name, :age, :weight, :height, :bravery
def initialize(name, age, weight, height, bravery)
@name = name
@age = age
@weight = weight
@height = height
var computer = "hpDesktop";
function apartmentOne() {
var computer = "iMac";
function bedroomOne() {
var computer = "macbookPro";
console.log("apartmentOne, bedroomOne uses computer: " + computer);
}
{
var fruit = "banana";
let vegetable = "carrot";
const spice = "paprika";
console.log("Inside the block...");
console.log("The fruit is: " + fruit);
console.log("The vegetable is: " + vegetable);
console.log("The spice is: " + spice);
}
var sandwich = "ham and cheese";
function eatSandwich() {
console.log("Now eating " + sandwich + "!");
}
function lunch() {
var sandwich = "BLT";
eatSandwich();
}
function setMovie(movie) {
this.movie = movie;
}
setMovie("Raiders of the Lost Ark");
console.log(window.movie); // "Raiders of the Lost Ark"
console.log(this.movie); // "Raiders of the Lost Ark"
console.log(movie); // "Raiders of the Lost Ark"
function setEntertainment(type, value) {
function setMovie(movie) {
this.movie = movie;
}
if (type === "movie") {
setMovie(value);
}
}
function setMovie(movie) {
this.movie = movie;
}
var theater = {
loadProjector: setMovie,
};
theater.loadProjector("The Princess Bride");
function setMovie(movie) {
this.movie = movie;
}
var theater = {
loadProjector: setMovie,
};
var television = {};