[finalElse,()=>"it's greater than or equal to 10"]
]
functionpatternMatcher(patterns){
return(input)=>{
consthead=patterns[0]// take the first pattern. the pattern is [condition, evaluator] or undefined
if(!head)thrownewError('No base case given')// if no pattern is found or given, throw error
constcondition=head[0]
constevaluator=head[1]
if(condition(input)){
returnevaluator()
}else{
returnpatternMatcher(patterns.slice(1))(input)
}
}
}
whatIsA=patternMatcher(myPatterns)
whatIsA('something')
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.