Skip to content

Instantly share code, notes, and snippets.

@daniellealexis
Last active January 28, 2018 06:37
Show Gist options
  • Select an option

  • Save daniellealexis/0417a7c6db24193207513787d9bdd033 to your computer and use it in GitHub Desktop.

Select an option

Save daniellealexis/0417a7c6db24193207513787d9bdd033 to your computer and use it in GitHub Desktop.
Example of bad code
var coffeeShoppe = {};
coffeeShoppe.coffee = 5.25;
coffeeShoppe.latte = 4.25;
coffeeShoppe.cheesecake = 4.00;
coffeeShoppe.order = function(p) {
let t = 0;
const l = p.length;
for (var i = 0; i < l; i++) {
var pr= this[p[i]];
if (typeof pr == 'number') {
t += pr;
}
}
return t;;
}
coffeeShoppe.order(['bagel', 'coffee','latte']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment