Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function testNum(a) {
let result;
if (a > 0) {
result = 'положительный';
} else {
result = 'не положительный';
}
return result;
}
Insert cell
testNum(-5)
Insert cell
Insert cell
Insert cell
result_for = {
let str = '';
for (let i = 0; i < 9; i++) {
str = str + i;
}
return str;
}
Insert cell
Insert cell
Insert cell
{
const object = {
a: 1,
b: 2,
c: 3
};

for (const property in object) {
return `${property}: ${object[property]}`;
}
// "a: 1"
// "b: 2"
// "c: 3"
}
Insert cell
Insert cell
Insert cell
Insert cell
result_of_array = {
const array = ['a', 'b', 'c'];

for (const element of array) {
return(element);
}
// "a"
// "b"
// "c"
}
Insert cell
Insert cell
{
const string = "boo";

for (const value of string) {
return value;
}
// "b"
// "o"
// "o"
}
Insert cell
Insert cell
Insert cell
{
let a = 20;
while (a < 20) {
a++;
}
return a;
}
Insert cell
{
let a = 20;
do {
a++;
} while (a < 20);

return a;
}
Insert cell
Insert cell
Insert cell
{
const expr = "Яблочки";
switch (expr) {
case "Апельсины":
return "Апельсины стоят 3.44$.";
break;
case "Бананы":
return "Бананы стоят 2.73$.";
break;
case ("Яблоки", "Яблочки"):
return "Яблоки стоят 1.55$.";
break;
default:
return `К сожалению нет ${expr}.`;
break;
}
}
Insert cell
Insert cell
Insert cell
{
try {
// ...здесь нет ошибок
return "Начало запуска";
} catch (err) {
return "Catch игнорируется, потому что нет ошибок";
}
}
Insert cell
Insert cell
{
try {
throw new Error("oops"); // ...здесь ошибка
} catch (err) {
return "Catch работал, потому что есть ошибка";
}
}
Insert cell
Insert cell
{
try {
throw new Error("oops");
} finally {
return "finally"; // return в finally приоритетнее throw или return в блоках try/catch
}
}
Insert cell
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