Fight Club

var Fight_Club = { 
    Tyler_Durdon: {  
        make_money: function() {
            var steps = [5, 6, 4, 4, 6, 6];
            for(var k=0, thoughts = 'it soap make sell waste steal liposuction'.split(' '); k<steps.length; k++) {                 
                var tmp = thoughts[k];                 
                thoughts[k] = thoughts[steps[k]];                  
                thoughts[steps[k]] = tmp;
            document.write(thoughts.join(' '));                            

Vote up this code13
  • Steven Linn

    Your ‘thoughts’ array would be overwritten every time the for loop loops. Also, you didn’t initialize the thoughts array.

  • Naden

    @Steve, you should test the code. Maybe the result will surprise you. It’s magic!

  • Dr. Lab Test-Ing.

    @steve you are wrong! The first block in the for() condition get’s run just once. It’s the initialisation part. Also in the same step “thoughts” gets initialized as an array not as a string. Javascript can be tricky