Published
Edited
Apr 29, 2022
1 fork
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof badGuessColor = Inputs.color({value: "#bb0000"})
Insert cell
viewof goodGuessColor = Inputs.color({value: "#16a716"})
Insert cell
focus = {
//feels like there's a better way to do this
guess;
document.getElementById('guess').focus()
}
Insert cell
drawRecord = (x) => {
return htl.html.fragment `<tr>
<td style="color:${x.points ? goodGuessColor : badGuessColor}">${x.guess}</td>
<td style="color:${x.points ? goodGuessColor : badGuessColor}">${x.currentWord}</td>
<td>${x.currentWord.length}</td>
</tr>
`
}
Insert cell
guessValue = {
while(true){
try {yield document.getElementById('guess').value.toUpperCase()}
catch {yield Promises.delay(100)}
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
currentNodes = [... new Set(currentWord.split(''))]
Insert cell
guessNodes = [... new Set(guessValue.split(''))]
Insert cell
goodGuessNodes = _.intersection(guessNodes, currentNodes)
Insert cell
badGuessNodes = _.difference(guessNodes, currentNodes)
Insert cell
handleEnter = (guess) => {
const isGoodGuess = guess.toUpperCase() === currentWord
const points = isGoodGuess ? 1 : 0

let scoreAfter = score + points
mutable score = scoreAfter
const ts = new Date()
log({guess: guess.toUpperCase(), currentWord, isGoodGuess, points})
mutable currentWord = pickWord2(wordLengthBounds[0], wordLengthBounds[1], minRepeatedLetters)
}
Insert cell
pickWord2 = (min, max, minRepeat) => {
let word = pickWord(min, max)
let i = 0
while (word.length - _.uniq(word.split('')).length < minRepeat && i < 3000) {
word = pickWord(min, max)
i++
}
return word
}
Insert cell
mutable currentWord = pickWord2(wordLengthBounds[0], wordLengthBounds[1], minRepeatedLetters)
Insert cell
mutable history = []
Insert cell
mutable score = 0
Insert cell
log = (data) => {
mutable history = [data, ...history]
}
Insert cell
import {pickWord} from '@a-lexwein/find-a-big-word-boggle-like'
Insert cell
import {rangeSlider} from '@mootari/range-slider@1312'
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