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 findSubsets(arr){ | |
| var subsets = [], | |
| permutations = getPermutations(arr,2); | |
| console.log(findInArr(arr, permutations)); | |
| return findInArr(arr, permutations).length; | |
| } | |
| function findInArr(arr, permutations){ | |
| var returnArr = [], sum; | |
| for(var i = 0; i<permutations.length; i++){ // iterate through each permutation |
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 merge(obj1, obj2){ | |
| var mergedObj = {}, subHash = {}; | |
| for(key in obj1){ | |
| mergedObj[key] = obj1[key]; | |
| } | |
| for(key in obj2){ // iterate through level1 keys of obj2 | |
| if(!mergedObj.hasOwnProperty(key)){ | |
| mergedObj[key] = obj2[key]; // if key of obj2 does not exist, add to mergedObj | |
| } else { | |
| subHash = mergedObj[key]; |
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
| <div id="container"></div> | |
| <div id="result"></div> | |
| <input type="submit" id="submit-button" /> | |
| <script> | |
| VIKI = { | |
| init: function(){ | |
| var inputs = this.createNodes(5); | |
| this.computeValue(inputs); |
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 secondLargest(arr){ | |
| var newArr = [], secondLargest; | |
| for(var i = 0; i < arr.length; i++){ | |
| if(arr[i] % 3 === 0){ | |
| newArr.push(arr[i]); | |
| } | |
| } | |
| newArr.sort(function(a,b){return a-b}); | |
| secondLargest = newArr[newArr.length - 1]; | |
| return secondLargest; |
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
| { | |
| "name": "chat-salon", | |
| "version": "0.0.1-18", | |
| "private": true, | |
| "scripts": { | |
| "test": "./bin/test", | |
| "start": "node app.js" | |
| }, | |
| "dependencies": { | |
| "express": "3.4.0", |
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
| // Object literal pattern aka Singleton | |
| var Animal = { | |
| speak: function(words){ | |
| console.log(words) | |
| } | |
| } | |
| // Module Pattern | |
| var Animal = (function(){ | |
| var internalVar = 1; |
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
| 'use strict'; | |
| function Calculator(){ | |
| } | |
| Calculator.prototype.add = function( int1, int2 ){ | |
| return int1 + int2; | |
| }; | |
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 findMin( A, K ){ | |
| var newArr = []; | |
| for(var i = 0; i< A.length; i++){ | |
| if(A[i-K+1] < A[i]){ | |
| newArr.push( A[i-K+1] ); | |
| } else { | |
| newArr.push( A[i] ); | |
| } |
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
| import React from 'react'; | |
| import Router from 'react-router'; | |
| import BrowserHistory from 'react-router/lib/History'; | |
| import App from './components/App.jsx'; | |
| import TaskList from './components/TaskList.jsx'; | |
| import { DefaultRoute, Link, Route, RouteHandler } from 'react-router'; | |
| var routes = ( | |
| <Route handler={App} path="/"> | |
| <DefaultRoute handler={App} /> |
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
| // 22: class - creation | |
| // To do: make all tests pass, leave the assert lines unchanged! | |
| describe('class creation', () => { | |
| it('is as simple as `class XXX {}`', function() { | |
| class TestClass {}; | |
| const instance = new TestClass(); | |
| assert.equal(typeof instance, 'object'); |