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 getElementsByClassName = function(className, element) { | |
| //creating resultArr to be returned | |
| var resultArr = []; | |
| var element = element || document.body; | |
| var targetNodes = element.childNodes; | |
| if (element.classList) { | |
| if (element.classList.contains(className)) { | |
| resultArr.push(element); | |
| } |
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 Queue = function() { | |
| var someInstance = {}; | |
| var size = 0; | |
| // Use an object with numeric keys to store values | |
| var storage = {}; | |
| // Implement the methods below | |
| someInstance.enqueue = function(value) { | |
| storage[size] = value; |
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 rockPaperScissors = function (numOfRounds) { | |
| var playerOptions = ['rock', 'scissors', 'paper']; | |
| var totalCases = []; | |
| var playGame = function(round, currentRound) { | |
| for (var i = 0; i < playerOptions.length; i++) { | |
| round.push(playerOptions[i]); | |
| if (currentRound === numOfRounds) { | |
| totalCases.push(round.slice()); | |
| } else { |
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 Node = function(value, next) { | |
| this.value = value; | |
| this.next = next; | |
| } | |
| var removeDuplicates = function(head) { | |
| var foundDuplicates = {}; | |
| var previous = null; | |
| var current = head; | |
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 bubbleSort = function(array) { // 2 1 6 3 | |
| var findSmallest = function(array) { | |
| var smallest = array[0]; | |
| for (var i = 1; i < array.length; i++) { | |
| if (array[i] < smallest) { | |
| smallest = array[i]; | |
| } | |
| } | |
| return smallest; |
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
| /** | |
| * Write a function `f(a, b)` which takes two strings as arguments and returns a | |
| * string containing the characters found in both strings (without duplication), in the | |
| * order that they appeared in `a`. Remember to skip spaces and characters you | |
| * have already encountered! | |
| * | |
| * Example: commonCharacters('acexivou', 'aegihobu') | |
| * Returns: 'aeiou' | |
| * | |
| */ |
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 findSmallest = function(array) { | |
| var smallest = array[0]; | |
| for (var i = 1; i < array.length; i++) { | |
| if (smallest > array[i]) { | |
| smallest = array[i]; | |
| } | |
| } | |
| return smallest; | |
| } |
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
| // helper function to get sum of the level array; | |
| var sumOfLevel = function(levelArray) { | |
| var sum = levelArray[0]; | |
| for (var i = 1; i < levelArray.length; i++) { | |
| sum += levelArray[i]; | |
| } | |
| return sum; | |
| } | |
| var compareSums = function(array) { |
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 generate = function(numRows) { | |
| var triangle = []; | |
| var firstRow = [1]; | |
| var secondRow = [1, 1]; | |
| if (numRows === 1) { | |
| return triangle.push(firstRow); | |
| } else if (numRows === 2) { | |
| triangle.push(firstRow); | |
| return triangle.push(secondRow); |
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 path = require('path'); | |
| var archive = require('../helpers/archive-helpers'); | |
| var fs = require('fs'); | |
| var httpHelpers = require('./http-helpers'); | |
| var headers = httpHelpers.headers | |
| // require more modules/folders here! | |
| var indexHTML = path.join(__dirname, '/public/index.html'); | |