Public
Edited
Feb 28, 2023
Fork of PSET 2
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
my[2]
Insert cell
roots = my.slice(0, 2);
Insert cell
my.push("last")
Insert cell
my
Insert cell
{
my.length
return my.length
}
Insert cell
{var index = my.indexOf("last");

if (~index) {
my[index] = "new";
}}
Insert cell
my
Insert cell
Insert cell
array1=['I', 'am', 'learning','Javascript','to','munge','large','datasets','and','visualize','them']
Insert cell
Insert cell
array1.join(" ");
Insert cell
array1.reverse(" ");
Insert cell
array1.sort();
Insert cell
array1.sort(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
Insert cell
array1.reverse(function (a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
});
Insert cell
Insert cell
myPlaces = ({
places: [{
name: "ElHatillo",
location: "Caracas",
latlon: [10.407231, "-66.842772"],
country: "Venezuela"
},
{
name: "Brooklyn",
location: "NY",
latlon: [40.674087, "-73.976372"],
country: "USA"
},
{
name: "myHouse",
location: "Cambridge",
latlon: [42.374912, "-71.110040"],
country: "USA"
},
{
name: "laPlaya",
location: "Culebra",
latlon: [18.318060, " -65.227887"],
country: "Puerto Rico"
},
{
name: "myGrandmas",
location: "Campania",
latlon: [40.567090, 15.494710],
country: "Italy"
} ],
topTwo:function () {
return [this.places[0].name.toUpperCase(), this.places[1].name.toUpperCase()]
}


})

Insert cell
myPlaces.topTwo()
Insert cell
myPlaces.places[0].latlon[0]
Insert cell
Insert cell
myPlaces.topTwo()
Insert cell
{ let age = 28;
if (age < 18) {
return ("you are not a banana");
} else {
return ("you are a banana");
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more