Skip to content

Instantly share code, notes, and snippets.

@AmaxJ
Created January 1, 2017 22:22
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 AmaxJ/e83ef4e7f91657e5497332a6349cb97b to your computer and use it in GitHub Desktop.
Save AmaxJ/e83ef4e7f91657e5497332a6349cb97b to your computer and use it in GitHub Desktop.
practice with dan
//Installed node modules: jquery underscore request express jade shelljs passport http sys lodash async mocha chai sinon sinon-chai moment connect validator restify ejs ws co when helmet wrench brain mustache should backbone forever debug
var _ = require('underscore');
var num = "the number: ";
var num2 = "10";
// console.log(num + num2)
var num3 = 42; //string //integer
var num4 = 12;
//console.log((num3+num3)*num2);
/*
15%
tip calculator:
1. Needs a value to calculate a tip for. //your input
2. multiply number by .15
*/
var bill = 50;
//console.log(bill * .15);
var bill2 = 60;
//function name //parameter
function calculateTip(billAmount) {
console.log(billAmount * .15);
}
// calculateTip(50) //
// calculateTip(64)
//sayHello("Alan"); // "Hello, Alan"
function sayHello() {
console.log("Hello there!");
}
var person = {
name: "Alan",
age: 28,
occupation: "Programmer",
sayHello: function() {
console.log("hello, my name is ", this.name);
}
}
//person.sayHello()
person.name //Alan
person.age // 28
var person2 = {
name: "Daniel",
age: 27,
hobbies: ["Drawing", "Gaming"],
sayGoodbye: function() {
console.log("goodbye, my name is ", this.name, "also i'm ", this.age, " years old.");
},
addtomyage: function (years) {
console.log(this.age + years);
}
}
//person2.addtomyage(10);
/*
if, else
*/
function checkAgeToDrink(age) {
if (age >= 21) {
console.log('this person can drink');
} else {
console.log('this person cannot drink');
}
}
//checkAgeToDrink(21)
//checkAgeToDrink(19)
//checkAgeToDrink(101)
/*
for loop, while loop
*/
function checkAge(year) {
var age = 2017 - year
if (age >= 21) {
console.log("They're a johnson and they only look too young");
} else if ( age > 75 ) {
console.log('theyre too old to drink');
} else {
console.log("They cannot drink");
}
}
//checkAge(1994)
//checkAge(1982)
//checkAge(1999)
//checkAge(1930)
/*
while(<some expression>) {
}
*/
//var counter = 10;
//while (counter > 5) {
// console.log("the counter is currently: " , counter);
// counter -= 1;
//}
// for(var i=0; i < 15; i+=1) {
// console.log("i currently equals ", i)
// console.log("i + 10 = ", i + 10);
// checkAgeToDrink(i + 10)
// console.log("--------------------------")
//}
//0
//1
//2
//3
var johnsonFamily = ["Alan", "dan", "myriame", "steve"];
var anotherList = [{ name: "alan", age: 28}, { name: "dan", age: 27}]
//for (var i=0; i < johnsonFamily.length; i++) {
// console.log("I =", i)
// console.log(johnsonFamily[i])
//}
for (var i=0; i < anotherList.length; i++) {
console.log(anotherList[i].name + " : " + anotherList[i].age)
}
function hello(name) {
console.log('hello', name)
}
/*
write a function called jumpingJack that takes a name as a parameter,
and logs out "<name> jumped over the hill"$
write a function called areYouRich that takes a dollar amount as a parameter,
. IF that dollar amount is below 100, prints "You're poor!", if the amount
is between 100 and 100000, prints "Youre doing pretty good", and if the amount
is more thatn 100000, prints "you're rich!"$
create an object for an airplane type, give it properties and a method
called fire guns that prints "<airplane name> is shooting its guns"$
ex:
var plane = {
type: "spitfire",
propellers: 2
}
create a list of russian cities that were captured by the germans in ww2
use a for loop to print out "the germans captures the city of <city name> during ww2"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment