Skip to content

Instantly share code, notes, and snippets.

@profesor79
Created March 20, 2018 17:33
Show Gist options
  • Save profesor79/b375e2e35114787c23296213142e7486 to your computer and use it in GitHub Desktop.
Save profesor79/b375e2e35114787c23296213142e7486 to your computer and use it in GitHub Desktop.
<p style="line-height: 18px; font-size: 18px; font-family: times;">
Click "<i>Load samples</i>" to view and edit more JS samples.<br>
<br>
Labyrinth generated with JavaScript:<br><br>
<script>
var firstBusObject ={busNumber:4,stops: [{in:3, out:1},{in:3, out:1},{in:3, out:1}]};
document.write('firstBusObject <br/>');
document.write(firstBusObject.busNumber);
document.write(' <br/>');
document.write(firstBusObject.stops[2].in);
document.write(' <br/>');
document.write(' <br/>');
var firstBus = new Array();
firstBus[0] ={in:3, out:1};
document.write('in then out: <br/>');
document.write(firstBus[0].in);
document.write(firstBus[0].out);
document.write('<br/>');
firstBus[1] = new Array (1,4);
firstBus[2] = new Array (3,0);
var secondBus = new Array();
secondBus[0] = [0,2];
secondBus[1] = new Array (1,1);
secondBus[2] = new Array (1,5);
secondBus[3] = new Array (1,3);
secondBus[4] = new Array (3,0);
var thirdBus = new Array();
thirdBus[0] = new Array (0,12);
thirdBus[1] = new Array (2,5);
thirdBus[2] = new Array (3,6);
thirdBus[3] = new Array (10,0);
var busStops = new Array (firstBus, secondBus, thirdBus);
document.write(busStops);
// code works up until here so far
var peopleCounter = 0;
for (var i = 0; i < busStops.length; i++) {
peopleCounter += busStops[i][1] - busStops[i][0];
document.write(peopleCounter);
document.write('<br/>');
};
</script>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment