Public
Edited
Jun 19, 2024
Insert cell
Insert cell
function sum(n) {
let res = 0;

for (let i = 1; i <= n; i++) {
res = res + i;
}

return res;
}
Insert cell
sum(5)
Insert cell
Insert cell
STORAGES2 =
[
['1.pic', '2.pic'],
['1.mov', '2.mov', '3.mov']
]
Insert cell
function listFiles2() {
let files = []
let folders1 = STORAGES2
for (let i = 0; i < folders1.length; i++) {
let files2 = folders1[i]
for (let j = 0; j < files2.length; j++) {
files.push(files2[j])
}
}
return files
}
Insert cell
listFiles2()
Insert cell
Insert cell
STORAGES3 =
[
[
['1.pic'],
'2.pic'
],
[
'1.mov',
['2.mov', '3.mov']
]
]
Insert cell
function listFiles3() {
let files = []
let folders1 = STORAGES3
for (let i = 0; i < folders1.length; i++) {
let foldersOrFiles2 = folders1[i]
for (let j = 0; j < foldersOrFiles2.length; j++) {
if (typeof foldersOrFiles2[j] == 'string') {
files.push(foldersOrFiles2[j])
} else {
let files3 = foldersOrFiles2[j]
for (let k = 0; k < files3.length; k++) {
files.push(files3[k])
}
}
}
}
return files
}
Insert cell
listFiles3()
Insert cell
stack = []
Insert cell
stack.push("a")
Insert cell
stack
Insert cell
stack.push("b")
Insert cell
stack
Insert cell
stack.push("c")
Insert cell
stack
Insert cell
stack.pop()
Insert cell
stack.pop()
Insert cell
stack.pop()
Insert cell
stack.pop()
Insert cell
function sumOverflow(n) {
return n + sumOverflow(n - 1);
}
Insert cell
sumOverflow(5)
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