Published
Edited
Mar 10, 2022
Insert cell
Insert cell
Insert cell
Insert cell
win = Math.random() * 10000
Insert cell
moreNuancedReaction(win)
Insert cell
// Beispiel für if/else
function reaction(winnings) {
let reaction;

if (winnings > 9000) {
reaction = "🤯";
} else {
reaction = "😄";
}

return reaction;
}
Insert cell
function moreNuancedReaction(winnings) {
let reaction;

if (winnings >= 9000) {
reaction = "🤯";
} else if (winnings >= 5000) {
reaction = "😄";
} else if (winnings >= 1000) {
reaction = "😅";
} else {
reaction = "😖";
}

return reaction + " " + winnings;
}
Insert cell
moreNuancedReaction2(5500)
Insert cell
function moreNuancedReaction2(winnings) {
let reaction;

if (winnings >= 1000) {
reaction = "😄";
}
if (winnings >= 5000) {
reaction = "😱";
}

return reaction;
}
Insert cell
Insert cell
// Beispiel für Switch
Insert cell
trafficLight = "go"
Insert cell
showTrafficLightBulb(trafficLight)
Insert cell
function showTrafficLightBulb(state) {
switch (state) {
case "go":
return "🟢";

case "wait":
return "🟠";

case "stop":
return "🔴";

default:
return "💥";
}
}
Insert cell
Insert cell
Insert cell
true || false
Insert cell
true || true
Insert cell
false || false
Insert cell
false || true
Insert cell
doYouLikeCorianderOrFennel = true || false
Insert cell
Insert cell
true && true
Insert cell
true && false
Insert cell
false && true
Insert cell
false && false
Insert cell
doYouLikeCorianderAndFennel = true && false
Insert cell
Insert cell
!false
Insert cell
!true
Insert cell
false && !true
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
200 > 100
Insert cell
100 < 200
Insert cell
200 < 100
Insert cell
Insert cell
zahl = 90
Insert cell
zahl >= 100
Insert cell
200 >= 200
Insert cell
200 > 200
Insert cell
Insert cell
200 === 200
Insert cell
120 === 200
Insert cell
"ein string" === "Ein String" || "tomate"
Insert cell
"ein string" === "Ein String"
Insert cell
Insert cell
Insert cell
"ein string" !== "Ein String"
Insert cell
"ein string" !== "ein string"
Insert cell
Insert cell
Insert cell
import { style } from "@cas-datenvisualisierung/style"
Insert cell
style
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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