Skip to content

Instantly share code, notes, and snippets.

@kevinmeziere
Created March 1, 2012 02:12
Show Gist options
  • Save kevinmeziere/1946687 to your computer and use it in GitHub Desktop.
Save kevinmeziere/1946687 to your computer and use it in GitHub Desktop.
JPCU JS-W12
var variable1;
var int1 = 255;
var float1 = 3.2;
var string1 = "this is a string";
var bool1 = true;
var array1 = ["item 1", 2, 3, "item 4"];
console.log("The value of float1 is " + float1);
console.log("The fourth item in array1 is :" + array1[3]);
var food3 = {
name:"soda",
color:"brown",
price:0.5
};
var object1 = {
name: "object 1",
outputText: "This is object 1",
idNumber: int1,
typesOfCars: ["ford", "Chevy", "buick"],
foods: [
{name:"cheese", color:"yellow", price: 2.50},
{name:"pizza", color:"red", price: 5.00},
food3
]
};
console.log(object1.outputText);
console.log(object1.idNumber);
console.log(object1.typesOfCars[1]);
console.log(object1.foods[1].color);
console.log(object1.foods[2].color);
/*
object: cube
*size
*color
-volume
-area
*/
function cube(incomingSize, incomingColor){
this.size = incomingSize;
this.color = incomingColor;
}
cube.prototype = {
size:0,
color:"none",
info: function(){
console.log("I am a size " + this.size +
" cube that is " + this.color +
" with a volume of " + this.volume() +
" and surface area of " + this.area() );
},
volume: function(){
return this.size * this.size * this.size;
},
area: function(){
return this.size * this.size * 6;
}
};
var cube1 = new cube(3, "red");
cube1.info();
var cube2 = new cube(4, "blue");
cube2.info();
var cube3 = new cube(9, "black");
cube3.info();
for(var i = 1; i <= 10; i++){
console.log(i);
}
var k = 1;
while(k <= 10){
console.log(k);
k++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment