Last active
August 29, 2015 13:56
-
-
Save yaroslavya/8957634 to your computer and use it in GitHub Desktop.
approach way to declare variables good vs bad in starwars universe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//bad | |
function(){ | |
var force = 0; | |
for(var i=0; i<500; i++){ | |
//using the force | |
force++; | |
} | |
var lightSaber = 0; | |
var siths = 100; | |
for(var siths=100; siths>0; siths--){ | |
lightSaber++; | |
} | |
var forceAndSaber = lightSaber.toString() + force.toString(); | |
console.log('if you use force with the saber its: ' + forceAndSaber); | |
console.log('number of siths remain: ' + siths); | |
} | |
//good | |
function(){ | |
var force = 0; | |
var lightSaber=0; | |
var forceAndSaber = ''; | |
var siths; | |
for(var i=0; i<500; i++){ | |
//using the force | |
force++; | |
} | |
for(siths=100; siths>0; siths--){ | |
//using the lightsaber, while decreasing number of siths. | |
lightSaber++; | |
} | |
forceAndSaber = lightSaber.toString() + force.toString(); | |
console.log('if you use force with the saber its: ' + forceAndSaber); | |
console.log('number of siths remain: ' + siths); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment