Published
Edited
Aug 31, 2020
Insert cell
Insert cell
aChar = "Hello There!"[6]
Insert cell
Insert cell
aSlice = "Hello There!".slice(6,11)
Insert cell
Insert cell
{
let orderNum = 8;
return `You are number ${orderNum + 1} in line.`;
}
Insert cell
Insert cell
Insert cell
Insert cell
d3.csv(
"https://cdn.rawgit.com/vlandham/js_data/master/data/cities_spaced.csv",
d => {
let cleanD = {};
for (let k of Object.keys(d)) {
cleanD[k.trim()] = d[k].trim();
}
return cleanD;
}
)
Insert cell
Insert cell
"A man, a plan, a canal".indexOf("man") !== -1
Insert cell
"A man, a plan, a canal".indexOf("panama") !== -1
Insert cell
Insert cell
"A man, a plan, a canal".replace("canal", "")
Insert cell
md`However, this will only replace the first occurence of the string. If you want to replace them all you need to use regular expressions`
Insert cell
"A man, a plan, a canal".replace(
/ a /g, // The /g specifies that we want to replace all instances
" the "
)
Insert cell
Insert cell
Insert cell
Insert cell
html_snippet = "<div class=\"person\">" +
"<span class=\"name\">" + person.name + "</span>" +
"<span class=\"occupation\">" + person.occupation + "</span>" +
"</div>"
Insert cell
Insert cell
`<div class="person">
<span class="name">${person.name}</span>
<span class="occupation">${person.occupation}</span>
</div>`
Insert cell
Insert cell
templateFunction = person =>
`<div class="person">
<span class="name">${person.name}</span>
<span class="occupation">${person.occupation}</span>
</div>`
Insert cell
templateFunction({ name : "James. James Bond", occupation: "Spy" })
Insert cell
Insert cell
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