Published
Edited
Mar 31, 2022
Importers
Insert cell
Insert cell
println = (string) => string
Insert cell
print = (string) => string
Insert cell
function prompt(question) {
return Inputs.text({label: question})
}
Insert cell
readNumber = (question) => {
let number = prompt(question)
return number
}
Insert cell
readLine = (question) => {
let line = prompt(question)
return line
}
Insert cell
readBoolean = (question) => {
let bool = prompt(question)
return bool
}
Insert cell
readInt = (question) => {
let int = prompt(question)
return int
}
Insert cell
Insert cell
class AlertBox extends HTMLElement {
connectedCallback() {
this.innerHTML = `<div style="min-width: 15rem; min-height: 8rem; padding: 2rem; border-radius: 10px; color: white; width: max-content; height: max-content; background-color: darkorange;">
<h2 style="color: white; padding-bottom: 1rem;">Alert:</h2>
<p>
${this.getAttribute("data-text")}
</p>
</div>`
}
}
Insert cell
defineCustomElements()
Insert cell
function alert(string) {
const regex = /[\r\n\x0B\x0C\u0085\u2028\u2029]+/g;
const parsedString = string.replace(regex, "<br><br>");
return html`
<alert-box data-text="${parsedString}"></alert-box>
`
}
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