marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 793 forks source link

Sandbox solution code for 8.1 is using 2nd edition's solution #475

Closed alexandersandberg closed 5 years ago

alexandersandberg commented 5 years ago

The code for 3rd edition's 8.1 exercise is using the following pre-filled code:

class MultiplicatorUnitFailure extends Error {}

function primitiveMultiply(a, b) {
  if (Math.random() < 0.2) {
    return a * b;
  } else {
    throw new MultiplicatorUnitFailure("Klunk");
  }
}

However, when showing the solution in the Code Sandbox, the following pre-filled code is used (from 2nd edition):

function MultiplicatorUnitFailure() {}

function primitiveMultiply(a, b) {
  if (Math.random() < 0.5) {
    return a * b;
  } else {
    throw new MultiplicatorUnitFailure();
  }
}

Steps to reproduce:

  1. Head to https://eloquentjavascript.net/code/#8.1
  2. Click on look at the solution at the bottom
marijnh commented 5 years ago

Thanks for noticing that! I had left in the 2nd edition code in the solution. Attached patch fixes it.