Public
Edited
Sep 9, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
paragraph = "JavaScript est un langage de script léger, orienté objet, principalement connu comme le langage de script des pages web. Mais il est aussi utilisé dans de nombreux environnements extérieurs aux navigateurs web tels que Node.js, Apache CouchDB voire Adobe Acrobat. Le code JavaScript est interprété ou compilé à la volée. C'est un langage à objets utilisant le concept de prototype, disposant d'un typage faible et dynamique qui permet de programmer suivant plusieurs paradigmes de programmation : fonctionnelle, impérative et orientée objet."
Insert cell
paragraph.length
Insert cell
Insert cell
words = paragraph.split(' ')
Insert cell
Insert cell
words.length
Insert cell
Insert cell
words[1]
Insert cell
Insert cell
p2 = paragraph.replace(/[,.:;]/g, "").split(' ')
Insert cell
new Set(p2).size
Insert cell
Insert cell
Insert cell
prices.milk
Insert cell
Insert cell
key = 'chips'
Insert cell
prices[key]
Insert cell
Insert cell
kv = [
["Pier", 30],
["Rosa", 80],
["Luke", 98],
["Mike", 29]
]
Insert cell
Object.fromEntries(kv)
Insert cell
Insert cell
values = [1, 4, 8, 10, 1, 3, 2, 8, 9, 10, 2, 21, 16, 21, 1, 4, 13, 10, 12, 4, 8, 12, 13, 21, 9, 0]
Insert cell
[...new Set(values)]
Insert cell
Insert cell
function counter(tableau) {
const o = {};
tableau.forEach((char) => {
if (o[char] === undefined) {
o[char] = 1;
} else {
o[char] += 1;
}
});
return o;
}
Insert cell
counter(values)
Insert cell
function counter2(tableau) {
const o = {};
for (let i=0; i < tableau.length; i++) {
const char = tableau[i];
if (o[char] === undefined) {
o[char] = 1;
} else {
o[char] += 1;
}
}
return o;
}
Insert cell
counter2(values)
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