Public
Edited
Jan 17, 2023
Insert cell
Insert cell
viewof text = Inputs.textarea({ rows: 20 })
Insert cell
Insert cell
viewof maxLengthWords = Inputs.text({ label: "Max length in words" })
Insert cell
viewof maxLengthCharacters = Inputs.text({ label: "Max length in characters" })
Insert cell
viewof goals = Inputs.textarea({
rows: 20,
label: "Notes on what you need to write"
})
Insert cell
numWords = text == "" ? 0 : text.split(/\s+/gi).length
Insert cell
numCharacters = text.trim().length
Insert cell
wordsLeft = {
let i = parseInt(maxLengthWords, 10);
if (isNaN(i)) {
return null;
}
return i;
}
Insert cell
charactersLeft = {
let i = parseInt(maxLengthCharacters, 10);
if (isNaN(i)) {
return null;
}
return i;
}
Insert cell
wordsMessage = {
if (wordsLeft === null) {
return "";
}
return wordsLeft - numWords;
}
Insert cell
charactersMessage = {
if (charactersLeft === null) {
return "";
}
return charactersLeft - numCharacters;
}
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