make_word4_sets.html

Eventually this is what we end up with - note that I've added a counter so we know how many sets our program found. Of course we now have to write word3.js and word4.js.

<script src='my_words4.js'></script>
<script src='word2.js'></script>
<script src='word3.js'></script>
<script src='word4.js'></script>
<script>
  var n=0;
  // try each word as the top word
  for (var i=0; i<my_words4.length; i++) {
    var w1=my_words4[i];
    var w2=word2(w1);
    if (w2!='') {
      var w3=word3(w1,w2);
      if (w3!='') {
        var w4=word4(w1,w2,w3);
        if (w4!='') {
          var s=w1+' '+w2+' '+w3+' '+w4+'<br>';
          document.write(s);
          n++;
        }
      }
    }
  }
  document.write(n);
</script>