Skip to content

Instantly share code, notes, and snippets.

View kotAPI's full-sized avatar
🎯
Focusing

Pranay Kothapalli kotAPI

🎯
Focusing
View GitHub Profile
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.
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
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",
function someFunction(){
console.log("I am a :" + this.thing);
console.log(this.somethingElse);
}
var object = {
thing : "programmer",
somethingElse:"somethingElse"
}
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"
}
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)
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()
@kotAPI
kotAPI / printpattern.js
Created December 3, 2018 09:33
Algorithm (Beginner)- Print the pattern - 332211
/*
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
/**
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;
@kotAPI
kotAPI / isAP.js
Last active December 5, 2018 13:04
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];