Skip to content

Instantly share code, notes, and snippets.

@yaroslavya
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaroslavya/8957634 to your computer and use it in GitHub Desktop.
Save yaroslavya/8957634 to your computer and use it in GitHub Desktop.
approach way to declare variables good vs bad in starwars universe
//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