This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myObject = { | |
name: "Matt Murdock", | |
age: 28, | |
callFunction:function(){ | |
console.log("My name is "+ this.name + " and I’m " +this.age+ " years old." | |
} | |
} | |
myObject.callFunction(); | |
//=> My name is Matt Murdock and I'm 28 years old. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var InventoryDetails = function(obj){ | |
obj.GetInventoryDetails = function(){ | |
console.log("You are "+this.name+ " and you have "+ this.pencils + " pencils and "+ this.pens+ " pens."); | |
} | |
} | |
var JackInventory = { | |
name:"Jack", | |
pencils:264, | |
pens:23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Company = function(name,worth){ | |
return{ | |
name:name, | |
worth:worth, | |
getNetWorth:function(){ | |
console.log("Name: "+this.name +", Worth :"+this.worth); | |
}, | |
company2:{ | |
name:"Acquired Company", | |
worth:"2Bn", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function someFunction(){ | |
console.log("I am a :" + this.thing); | |
console.log(this.somethingElse); | |
} | |
var object = { | |
thing : "programmer", | |
somethingElse:"somethingElse" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function printList(object1,object2,object3,object4,object5){ | |
console.log(object1+" "+object2+" "+object3+" "+object4+" "+object5); | |
console.log(this.misc); | |
} | |
var object = { | |
ListOfObjects:["element1","element2","element3","element4","element5"], | |
misc:"somethingElse" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Car = function(wheels, price, topSpeed){ | |
this.wheels = wheels; | |
this.price = price; | |
this.topSpeed = topSpeed; | |
} | |
function vroom(){ | |
console.log("Let's vroom with "+ this.wheels + " wheels on my "+ this.price +" $ car at "+this.topSpeed+" miles/hr"); | |
} | |
var newCar = new Car(4,40000,400) | |
vroom.call(newCar) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Car = function(wheels, price, topSpeed){ | |
this.wheels = wheels; | |
this.price = price; | |
this.topSpeed = topSpeed; | |
} | |
function vroom(){ | |
console.log("Let's vroom with "+ this.wheels + " wheels on my "+ this.price +" $ car at "+this.topSpeed+" miles/hr"); | |
} | |
var newCar = new Car(4,40000,400) | |
vroom() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
3 3 3 2 2 2 1 1 1 | |
3 3 2 2 1 1 | |
3 2 1 | |
*/ | |
var N=4 | |
for(var i=N;i>0;i--){ | |
// Every line that needs to be logged on every iteration of N | |
var line = "" | |
// Populating every line with numbers by iterating |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
2 x 95 = 190 | |
2 x 96 = 192 | |
2 x 97 = 194 | |
2 x 98 = 196 | |
2 x 99 = 198 | |
2 x 100 = 200 | |
*/ | |
var N = 2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var seriesAP = [5,9,13,17,21,25,29,33,37,41] | |
function isAP(series){ | |
if(series.length<2){ | |
// not a valid series | |
} | |
// find the difference(d) of the series, if it is an arithmetic progression | |
// the difference of first two elements should suffice | |
var d = series[1]-series[0]; |
OlderNewer