Skip to content

Instantly share code, notes, and snippets.

View karenpeng's full-sized avatar
🏠
Working from home

Karen Peng karenpeng

🏠
Working from home
View GitHub Profile
function quickSort(arr) {
var less = more = pivots = [];
if (arr.length > 1) {
pivot = arr[0];
arr.forEach(function (i) {
if (i < pivot) {
less.push(i);
console.log(i)
foo();
var test;
function foo(){
function bar() {
test = console.trace();
}
bar();
}
// When your server receives a request on
// http://localhost:4000/set?somekey=somevalue
// it should store the passed key and value in memory.
// When it receives a request on
// http://localhost:4000/get?key=somekey
// it should return the value stored at somekey.
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var test = [1,2,3]
function check(arr){
arr.forEach(function(el){
if(el === 2){
console.log('ouch')
return true;
}
})
return false;
// init renderer
var renderer = new THREE.WebGLRenderer({
antialias : true,
});
renderer.setClearColor(new THREE.Color('lightgrey'), 1)
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
// init scene and camera
var scene = new THREE.Scene();
var nodes = []
var colors = ['r', 'g', 'b', 'y']
function Node(left, right, up, down, color) {
this.left = left
this.right = right
this.up = up
this.down = down
this.color = color
this.checked = false
function Car(name) {
this.name = name;
}
Car.prototype.display = function () {
console.log(this.name);
}
var benz = new Car('benz');
benz.display(); // benz, this === benz
function bumang(i){
return function(){
console.log(i)
}
}
for(var i = 0; i< 10; i++){
setTimeout(
bumang(i)
, i * 1000);
this.x = 9;
var module = {
x: 81,
getX: function() { return this.x; }
};
module.getX(); // 81
var getX = module.getX;
var animals = [
{ species: 'Lion', name: 'King' },
{ species: 'Whale', name: 'Fail' }
];
for(var i = 0; i < animals.length; i++){
(function(i){
this.print = function(){
console.log(i + ' ' + this.species + ' ' + this.name)