// convenience function for deriving current from voltage and resistance
returnv/r;
}
digitsToSegments=[6,2,5,5,4,5,5,3,7,5]
expectedTotalCurrent=digitsToSegments
.map((d)=>(d*currentPerSegmentInMilliAmps)/16)
.reduce((p,c)=>p+c)
selectedCurrent={
if(typeofselectedDigit=="number"){
return(
digitsToSegments[selectedDigit]*
currentPerSegmentInMilliAmps*
numberOfDigits
);
}else{
returnexpectedTotalCurrent*numberOfDigits;
}
}
expectedBatteryLife=batterymAh/selectedCurrent
sum4=function(x){
returnosc1(x)+osc2(x)+osc3(x)+osc4(x);
}
osc1=function(x){
returnMath.sin(x*freq1)>0?1:0;
}
osc2=function(x){
returnMath.sin(x*freq2)>0?2:0;
}
osc3=function(x){
returnMath.sin(x*freq3)>0?4:0;
}
osc4=function(x){
returnMath.sin(x*freq4)>0?8:0;
}
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.