Skip to content

Instantly share code, notes, and snippets.

@luisangelma
luisangelma / main.js
Last active November 19, 2015 23:06
Penguins VS Communists
var Party = function(name) {
var self = this;
this.name = name;
this.population = 1000000;
this.getAttacked = function(nuke) {
self.population -= nuke.impact;
if(self.population <= 0) {
self.population = 0;
}
<!DOCTYPE html>
<html ng-app="mainApp">
<head>
<title>Angular Setup</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body ng-controller="mainController">
<div class="jumbotron">
// Warmup Enemy generator
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var Enemy = function() {
var self = this;
@luisangelma
luisangelma / gist:964f8d7f529e36d6be9a
Created July 16, 2015 21:26
Loops & Arrays (odd/evens)
function createEvenArray(highNum) {
var array = [];
for(var i = highNum; i > 0; i-=2) {
array.unshift(i);
}
console.log(array);
@luisangelma
luisangelma / gist:cded0621ba72ff104048
Created July 16, 2015 19:03
Vowels and Consonants
function getVowels(str) {
var numberOfVowels = 0;
var strArray = str.split('');
for (var i = 0; i < strArray.length; i++ ) {
switch(strArray[i]) {
case 'a':
numberOfVowels++;