Public
Edited
Apr 8, 2023
Insert cell
Insert cell
Insert cell
x = 5;
Insert cell
Insert cell
y = x + 9;
Insert cell
Insert cell
Insert cell
z = x + y;
Insert cell
Insert cell
p = "Hello ";
Insert cell
q = "world!"
Insert cell
p + q
Insert cell
Insert cell
square = function(value){
return value*value;
}
Insert cell
x2 = square(x);
Insert cell
Insert cell
function1 = function(d){
return d + 1
}
Insert cell
d = 7
Insert cell
Insert cell
function sum(value1, value2) {
return value1 + value2;
}
Insert cell
a = sum(x,y);
Insert cell
Insert cell
htmlcreator = function(word){
return html`<p>Hello <b>${word}</b>!</p>`;
}
Insert cell
htmlcreator("world");
Insert cell
htmlcreator("team");
Insert cell
Insert cell
square2 = (x)=>x*x;
Insert cell
x22 = square2(x);
Insert cell
mult = (a,b)=>a*b;
Insert cell
ab = mult(x,y);
Insert cell
square3 = (x)=>{
console.log("help!!");
console.log(x);
return x*x
};
Insert cell
Insert cell
sum3 = (value1, value2)=> value1 + value2;
Insert cell
Insert cell
person1 = ({
name: "Mary",
surname: "Acharya",
age: 30,
height: 61
})
Insert cell
Insert cell
person1.name
Insert cell
person1["name"]
Insert cell
person1.height
Insert cell
Insert cell
person2 = ({
name: "Bilal",
surname: "Uwir",
age: 28,
height: 76,
fullname: function(){return this.name+ ' ' + this.surname;}
})
Insert cell
person2.fullname()
Insert cell
undefined == null
Insert cell
true == 0

Insert cell
Insert cell
ar = ['a', 'b', 'c'];
Insert cell
totalar2 = ar.reduce((str, d) => str + d + " ", "");
Insert cell
totalar3 = ar.reduce(function(string, d) {
return string + d + " "},)
Insert cell
ar.length
Insert cell
ar[2]
Insert cell
Insert cell
weather = await FileAttachment("GironaWeatherData.csv").csv();
Insert cell
Insert cell
Insert cell
Insert cell
// desiredData = weather.map(d => {
// var newd = {
// date : new Date(d["Date time"]),
// maxTemp : +d["Maximum Temperature"],
// minTemp : +d["Minimum Temperature"],
// condition : d["Conditions"], //d.Conditions
// precipitation : +d["Precipitation"]
// }
// return newd;
// });

desiredData = weather.map(d => ({
date: new Date(d["Date time"]),
maxTemp: +d["Maximum Temperature"],
minTemp: +d["Minimum Temperature"],
condition: d["Conditions"],
precipitation: +d["Precipitation"]
}));
Insert cell
arNew = ar.map(d => {
return d+d
})
Insert cell
Insert cell
newar = ar.map(d => d+d);
Insert cell
Insert cell
selectedData = desiredData.filter(d => {
var startDate = new Date("09/01/2020");
var endDate = new Date("09/30/2020");
return d.date >= startDate && d.date <= endDate;
});
Insert cell
selectedData2 = desiredData.filter(d=> d.maxTemp > 30);
Insert cell
selectedData3 = desiredData.filter(d => {
return d.maxTemp > 28
});
Insert cell
Insert cell
sortedData =selectedData.sort((a,b) => {
return a.maxTemp - b.maxTemp;
});

Insert cell
sortedData2 =selectedData.sort((x,y) => {
return y.maxTemp - x.maxTemp;
});

Insert cell
Insert cell
totalPrecipitation = desiredData.reduce((accum, d) => accum + d.precipitation, 0);
Insert cell
Insert cell
totalar = ar.reduce((str, d) => str + d + " ", "");
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