Skip to content

Instantly share code, notes, and snippets.

@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++;
@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);
// Warmup Enemy generator
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
var Enemy = function() {
var self = this;
<!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">
@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;
}
@luisangelma
luisangelma / main.js
Last active November 19, 2015 23:05
Call Me Maybe
var namesArray = ['angela', 'troy', 'ana', 'mark', 'amit', 'peter', 'john', 'gary', 'melissa', 'jacob'];
var dontCall = function(name) {
console.log('Not calling ' + name);
};
var call = function(name) {
console.log('Calling ' + name);
};
@luisangelma
luisangelma / main.js
Created August 4, 2015 00:35
Dictionary
var Dictionary = function() {
var self = this;
var words = []
this.acceptWord = true;
this.addWord = function(word, def) {
words.push({
reference: word.toLowerCase(),
@luisangelma
luisangelma / index.html
Created August 4, 2015 00:37
Angular Project Refreshner
<!DOCTYPE html>
<html ng-app="mainApp">
<head>
<title>Angular Site</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
</head>
<body>
<section ng-controller="sumController">
<h2> {{ sumValue }} (Added Value) </h2>
@luisangelma
luisangelma / main.js
Created August 4, 2015 00:38
RPG Game
var readlineSync = require('readline-sync');
var name = readlineSync.question('Hey stranger, what is your name?: ');
var wildAdventure = function() {
var self = this;
var enemies = ['White Walker', 'White Orc', 'Wild Dragon'];
var enemy;
var randomEnemy = function() {
return Math.floor(Math.random() * ((enemies.length - 1) - 0 + 1)) + 0;
@luisangelma
luisangelma / index.html
Created August 4, 2015 00:42
Angular todo list
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body ng-app="myApp" ng-controller="mainController">
<p>Add an item</p>