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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more