Public
Edited
Feb 14, 2023
Insert cell
Insert cell
Insert cell
x = 6;
Insert cell
Insert cell
y = x + 2;
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){
let sq = value*value;
return sq;
}
Insert cell
x2 = square(x);
Insert cell
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 "Hello " + word + "!";
}
Insert cell
htmlcreator("world");
Insert cell
htmlcreator("students");
Insert cell
html`<h2>Hello!</h2>`
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
sqaure3 = (x)=>{
console.log("Help!!!");
console.log(x);
return x*x
};
Insert cell
xx=sqaure3(3);
Insert cell
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
Insert cell
person2 = ({
name: "Bilal",
surname: "Uwir",
age: 28,
height: 76,
fullname: function(){return this.name+ ' ' + this.surname;}
})
Insert cell
person2.fullname()
Insert cell
Insert cell
ar = ['a', 'bd', 'c', 'j'];
Insert cell
ar.length
Insert cell
ar[2]
Insert cell
ar[1]
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;
});
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
Insert cell
sortedData =selectedData.sort((a,b) => b.maxTemp - a.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