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
arr = [“a”, “b”, “c”] | |
arr[1] # => “b” | |
arr[1] = “z” | |
arr[1] # => “z” |
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 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 |
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 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 |
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 computer = "hpDesktop"; | |
function apartmentOne() { | |
var computer = "iMac"; | |
function bedroomOne() { | |
var computer = "macbookPro"; | |
console.log("apartmentOne, bedroomOne uses computer: " + computer); | |
} | |
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 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); | |
} |
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 sandwich = "ham and cheese"; | |
function eatSandwich() { | |
console.log("Now eating " + sandwich + "!"); | |
} | |
function lunch() { | |
var sandwich = "BLT"; | |
eatSandwich(); | |
} |
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
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" |
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
function setEntertainment(type, value) { | |
function setMovie(movie) { | |
this.movie = movie; | |
} | |
if (type === "movie") { | |
setMovie(value); | |
} | |
} |
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
function setMovie(movie) { | |
this.movie = movie; | |
} | |
var theater = { | |
loadProjector: setMovie, | |
}; | |
theater.loadProjector("The Princess Bride"); |
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
function setMovie(movie) { | |
this.movie = movie; | |
} | |
var theater = { | |
loadProjector: setMovie, | |
}; | |
var television = {}; |