MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript / primitiveMultiply

Function primitiveMultiply

code/solutions/08_1_retry.js:3–9  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

1class MultiplicatorUnitFailure extends Error {}
2
3function primitiveMultiply(a, b) {
4 if (Math.random() < 0.2) {
5 return a * b;
6 } else {
7 throw new MultiplicatorUnitFailure("Klunk");
8 }
9}
10
11function reliableMultiply(a, b) {
12 for (;;) {

Callers 1

reliableMultiplyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected